Anything But Typical Learning to Love JavaScript Prototypes Page 1 © 2010 Razorfish. All rights reserved. Dan Nichols March 14, 2010.

Slides:



Advertisements
Similar presentations
Numbers Treasure Hunt Following each question, click on the answer. If correct, the next page will load with a graphic first – these can be used to check.
Advertisements

EcoTherm Plus WGB-K 20 E 4,5 – 20 kW.
2 Casa 15m Perspectiva Lateral Izquierda.
Repaso: Unidad 2 Lección 2
1 A B C
Scenario: EOT/EOT-R/COT Resident admitted March 10th Admitted for PT and OT following knee replacement for patient with CHF, COPD, shortness of breath.
Simplifications of Context-Free Grammars
Variations of the Turing Machine
AP STUDY SESSION 2.
1
Slide 1Fig 25-CO, p.762. Slide 2Fig 25-1, p.765 Slide 3Fig 25-2, p.765.
Slide 1Fig 39-CO, p Slide 2Fig 39-1, p.1246.
Select from the most commonly used minutes below.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
David Burdett May 11, 2004 Package Binding for WS CDL.
NTDB ® Annual Report 2009 © American College of Surgeons All Rights Reserved Worldwide Percent of Hospitals Submitting Data to NTDB by State and.
Local Customization Chapter 2. Local Customization 2-2 Objectives Customization Considerations Types of Data Elements Location for Locally Defined Data.
Create an Application Title 1Y - Youth Chapter 5.
CALENDAR.
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt BlendsDigraphsShort.
CHAPTER 18 The Ankle and Lower Leg
1 Click here to End Presentation Software: Installation and Updates Internet Download CD release NACIS Updates.
The 5S numbers game..
Media-Monitoring Final Report April - May 2010 News.
Break Time Remaining 10:00.
Turing Machines.
Table 12.1: Cash Flows to a Cash and Carry Trading Strategy.
PP Test Review Sections 6-1 to 6-6
MM4A6c: Apply the law of sines and the law of cosines.
Bellwork Do the following problem on a ½ sheet of paper and turn in.
K ONTRAK PERKULIAHAN I Made Gatot K, ST. MT 1. PENILAIAN Kehadiran min 75 % : 5 % Tugas: 20 % Diskusi / Presentasi: 20 % UTS: 25 % UAS: 30 % TOTAL: 100%
1 The Royal Doulton Company The Royal Doulton Company is an English company producing tableware and collectables, dating to Operating originally.
Operating Systems Operating Systems - Winter 2010 Chapter 3 – Input/Output Vrije Universiteit Amsterdam.
Exarte Bezoek aan de Mediacampus Bachelor in de grafische en digitale media April 2014.
TESOL International Convention Presentation- ESL Instruction: Developing Your Skills to Become a Master Conductor by Beth Clifton Crumpler by.
Sample Service Screenshots Enterprise Cloud Service 11.3.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
1 RA III - Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Buenos Aires, Argentina, 25 – 27 October 2006 Status of observing programmes in RA.
1..
Adding Up In Chunks.
SLP – Endless Possibilities What can SLP do for your school? Everything you need to know about SLP – past, present and future.
MaK_Full ahead loaded 1 Alarm Page Directory (F11)
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt Synthetic.
Artificial Intelligence
Before Between After.
Subtraction: Adding UP
1 Lab 17-1 ONLINE LESSON. 2 If viewing this lesson in Powerpoint Use down or up arrows to navigate.
Bell Busters! Unit 1 #1-61. Purposes of Government 1. Purposes of government 2. Preamble to the Constitution 3. Domestic tranquility 4. Common defense.
: 3 00.
5 minutes.
1 hi at no doifpi me be go we of at be do go hi if me no of pi we Inorder Traversal Inorder traversal. n Visit the left subtree. n Visit the node. n Visit.
Types of selection structures
Speak Up for Safety Dr. Susan Strauss Harassment & Bullying Consultant November 9, 2012.
Essential Cell Biology
Converting a Fraction to %
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Clock will move after 1 minute
famous photographer Ara Guler famous photographer ARA GULER.
PSSA Preparation.
Physics for Scientists & Engineers, 3rd Edition
Energy Generation in Mitochondria and Chlorplasts
Select a time to count down from the clock above
Copyright Tim Morris/St Stephen's School
1.step PMIT start + initial project data input Concept Concept.
1 Dr. Scott Schaefer Least Squares Curves, Rational Representations, Splines and Continuity.
1 Non Deterministic Automata. 2 Alphabet = Nondeterministic Finite Accepter (NFA)
Presentation transcript:

Anything But Typical Learning to Love JavaScript Prototypes Page 1 © 2010 Razorfish. All rights reserved. Dan Nichols March 14, 2010

JavaScript Page 2 © 2010 Razorfish. All rights reserved.

Object-Oriented Programming Page 3 © 2010 Razorfish. All rights reserved.

class Page 4 © 2010 Razorfish. All rights reserved.

Inheritance Page 5 © 2010 Razorfish. All rights reserved.

prototype (not the library) Page 6 © 2010 Razorfish. All rights reserved.

The story so far… Page 7 © 2010 Razorfish. All rights reserved.

Page 8 © 2010 Razorfish. All rights reserved.

Page 9 © 2010 Razorfish. All rights reserved.

…except it wasnt all good. Page 10 © 2010 Razorfish. All rights reserved.

Page 11 © 2010 Razorfish. All rights reserved.

Page 12 © 2010 Razorfish. All rights reserved.

Page 13 © 2010 Razorfish. All rights reserved.

Page 14 © 2010 Razorfish. All rights reserved.

Sound familiar? Page 15 © 2010 Razorfish. All rights reserved.

Page 16 © 2010 Razorfish. All rights reserved. prototype (not the library) to the rescue!

Page 17 © 2010 Razorfish. All rights reserved. Everything is an object

Page 18 © 2010 Razorfish. All rights reserved. Every object has a prototype

Page 19 © 2010 Razorfish. All rights reserved. prototype s do good things

Page 20 © 2010 Razorfish. All rights reserved. Encourage modularity and reusability

Page 21 © 2010 Razorfish. All rights reserved. Provide a consistent way to do (different) things

Page 22 © 2010 Razorfish. All rights reserved. Keep code to a minimum

Page 23 © 2010 Razorfish. All rights reserved. Make complexity easy

What is a prototype, exactly? Page 24 © 2010 Razorfish. All rights reserved.

Page 25 © 2010 Razorfish. All rights reserved. A reference point for other objects

Property lookup chain Page 26 © 2010 Razorfish. All rights reserved.

Property lookup chain Page 27 © 2010 Razorfish. All rights reserved. instance Date Object

Property lookup chain Page 28 © 2010 Razorfish. All rights reserved. instance Date Object

Property lookup chain Page 29 © 2010 Razorfish. All rights reserved. instance Date Object

Property lookup chain Page 30 © 2010 Razorfish. All rights reserved. instance Date Object

Page 31 © 2010 Razorfish. All rights reserved. JavaScript is different from most other OOP languages

Anatomy of a prototype Page 32 © 2010 Razorfish. All rights reserved. rex Poodle Dog Object

Anatomy of a prototype Page 33 © 2010 Razorfish. All rights reserved. Constructor

Anatomy of a prototype Page 34 © 2010 Razorfish. All rights reserved. Property Method

Anatomy of a prototype Page 35 © 2010 Razorfish. All rights reserved. Constructor Inheritance

Anatomy of a prototype Page 36 © 2010 Razorfish. All rights reserved. Instance Instance Property

this and the lookup chain Page 37 © 2010 Razorfish. All rights reserved. fluffy Cat Object socks

this and the lookup chain Page 38 © 2010 Razorfish. All rights reserved. socks Cat Object

this and the lookup chain Page 39 © 2010 Razorfish. All rights reserved. fluffy Cat Object

Execution context: this and call() Page 40 © 2010 Razorfish. All rights reserved.

Execution context: this and call() Page 41 © 2010 Razorfish. All rights reserved.

Execution context with instances Page 42 © 2010 Razorfish. All rights reserved. Same outcome

Page 43 © 2010 Razorfish. All rights reserved. Inheritance

Working with inherited behavior Page 44 © 2010 Razorfish. All rights reserved. LimitedContainer Container Object

Working with inherited behavior Page 45 © 2010 Razorfish. All rights reserved. LimitedContainer Container Object

Working with inherited behavior Page 46 © 2010 Razorfish. All rights reserved. LimitedContainer Container Object

Page 47 © 2010 Razorfish. All rights reserved. JavaScript is the Frankenstein of the OOP world

Borrowing from multiple prototypes Page 48 © 2010 Razorfish. All rights reserved.

Page 49 © 2010 Razorfish. All rights reserved. One small problem

The constructor problem Page 50 © 2010 Razorfish. All rights reserved.

The constructor problem Page 51 © 2010 Razorfish. All rights reserved.

Fixing the constructor problem Page 52 © 2010 Razorfish. All rights reserved.

Fixing the constructor problem Page 53 © 2010 Razorfish. All rights reserved.

Page 54 © 2010 Razorfish. All rights reserved. prototype isnt love at first sight

Page 55 © 2010 Razorfish. All rights reserved. Putting prototype s to work

Requirements Four kinds of rules on the form: Required Number Zip Code Multiple rules can apply to one field Rules need to be inferred from data-rich, standard HTML Error messages should be specific Flexible enough to be: Usable for all other forms on the site Extended for use in other projects Page 56 © 2010 Razorfish. All rights reserved.

The Plan On load: 1.Create validation rules for each field 2.Set up submit handler When form is submitted: 1.Cycle through all rules 2.If a field fails a rule Mark it invalid Create an error message for it Dont check any more rules for that field 3.Show all error messages Page 57 © 2010 Razorfish. All rights reserved.

Page 58 © 2010 Razorfish. All rights reserved. ValidatingForm Object Validator NumberValidator PatternValidator RequiredValidator Validator

Page 59 © 2010 Razorfish. All rights reserved. Libraries are there to make life easier

Page 60 © 2010 Razorfish. All rights reserved. Think about your approach

Page 61 © 2010 Razorfish. All rights reserved. Dive in!

Thank You Dan Nichols Blog: Code demo: Page 62 © 2010 Razorfish. All rights reserved.