SlideShare ist ein Scribd-Unternehmen logo
1 von 66
Downloaden Sie, um offline zu lesen
OO JavaScript
                          Class Construction
                           Using The Prototype JavaScript Framework
                                             July 8th 2008
                                    Ken Collins http://metaskills.net/




Thursday, July 10, 2008                                                  1
Topic Overview




Thursday, July 10, 2008                    2
Topic Overview
                     • Basic JavaScript Refresher




Thursday, July 10, 2008                             2
Topic Overview
                     • Basic JavaScript Refresher
                     • The Ruby Object Model




Thursday, July 10, 2008                             2
Topic Overview
                     • Basic JavaScript Refresher
                     • The Ruby Object Model
                     • JavaScript Code Usage/Organization Types



Thursday, July 10, 2008                                           2
Topic Overview
                     • Basic JavaScript Refresher
                     • The Ruby Object Model
                     • JavaScript Code Usage/Organization Types
                     • Prototype Class Construction


Thursday, July 10, 2008                                           2
Topic Overview
                     • Basic JavaScript Refresher
                     • The Ruby Object Model
                     • JavaScript Code Usage/Organization Types
                     • Prototype Class Construction
                     • Review HomeMarks v2.0

Thursday, July 10, 2008                                           2
Basic JavaScript
            Refresher

Thursday, July 10, 2008      3
Basic JavaScript Refresher




Thursday, July 10, 2008                                4
Basic JavaScript Refresher
                 •        JavaScript is a prototype-based language.




Thursday, July 10, 2008                                               4
Prototype-based programming is a style of object-oriented
            programming in which classes are not present, and behavior
               reuse (known as inheritance in class-based languages) is
               performed via a process of cloning existing objects that
            serve as prototypes. This model can also be known as class-
              less, prototype-oriented or instance-based programming.




                          http://en.wikipedia.org/wiki/Prototype-based_programming


Thursday, July 10, 2008                                                              5
Basic JavaScript Refresher
                 •        JavaScript is a prototype-based language.




Thursday, July 10, 2008                                               6
Basic JavaScript Refresher
                 •        JavaScript is a prototype-based language.

                 •        JavaScript objects are best thought about as hashes.
                          New values and even functions can just be tacked
                          on.




Thursday, July 10, 2008                                                          6
JavaScript Object Model




Thursday, July 10, 2008                             7
JavaScript Object Model




Thursday, July 10, 2008                             7
Basic JavaScript Refresher
                 •        JavaScript is a prototype-based language.

                 •        JavaScript objects are best thought about as hashes.
                          New values and even functions can just be tacked
                          on.




Thursday, July 10, 2008                                                          8
Basic JavaScript Refresher
                 •        JavaScript is a prototype-based language.

                 •        JavaScript objects are best thought about as hashes.
                          New values and even functions can just be tacked
                          on.

                 •        Get firebug and use console.log() liberally!




Thursday, July 10, 2008                                                          8
http://getrebug.com/releases/




Thursday, July 10, 2008                                    9
Thursday, July 10, 2008   10
Basic JavaScript Refresher
                 •        JavaScript is a prototype-based language.

                 •        JavaScript objects are best thought about as hashes.
                          New values and even functions can just be tacked
                          on.

                 •        Get firebug and use console.log() liberally!




Thursday, July 10, 2008                                                          11
Basic JavaScript Refresher
                 •        JavaScript is a prototype-based language.

                 •        JavaScript objects are best thought about as hashes.
                          New values and even functions can just be tacked
                          on.

                 •        Get firebug and use console.log() liberally!

                 •        Remember, that functions are objects too.
                          With non-strict argument options.




Thursday, July 10, 2008                                                          11
Thursday, July 10, 2008   12
Basic JavaScript Refresher
                 •        JavaScript is a prototype-based language.

                 •        JavaScript objects are best thought about as hashes.
                          New values and even functions can just be tacked
                          on.

                 •        Get firebug and use console.log() liberally!

                 •        Remember, that functions are objects too.
                          With non-strict argument options.

                 •        Knowing what “this” is can save you lots of
                          debugging and headaches. (another topic)

Thursday, July 10, 2008                                                          13
The Ruby
                 Object Model
               Knowing Ruby’s object model will help you with
               Prototype’s class construction and how it mimics
                            inheritance and mixins.



Thursday, July 10, 2008                                           14
Inheritance in Ruby




Thursday, July 10, 2008                         15
Module Mixins in Ruby




Thursday, July 10, 2008                           16
Prototyping in Ruby




Thursday, July 10, 2008                         17
http://www.pragprog.com/screencasts/v-dtrubyom/the-ruby-object-model-and-metaprogramming




Thursday, July 10, 2008                                                                          18
JavaScript Code
                     Usage/Organization
                           Types


Thursday, July 10, 2008                   19
JavaScript Code Usage/
                            Organization Types




Thursday, July 10, 2008                            20
JavaScript Code Usage/
                            Organization Types

                     • Oh so uncool inline events.
                     • Procedural functions at the window level.



Thursday, July 10, 2008                                            20
Inheritance in Ruby




Thursday, July 10, 2008                         21
JavaScript Code Usage/
                            Organization Types

                     • Oh so uncool inline events.
                     • Procedural functions at the window level.



Thursday, July 10, 2008                                            22
JavaScript Code Usage/
                              Organization Types

                     • Oh so uncool inline events.
                     • Procedural functions at the window level.
                     • Namespaced modules. Essentially just a
                          hash of stateless functions.




Thursday, July 10, 2008                                            22
Inheritance in Ruby




Thursday, July 10, 2008                         23
JavaScript Code Usage/
                              Organization Types

                     • Oh so uncool inline events.
                     • Procedural functions at the window level.
                     • Namespaced modules. Essentially just a
                          hash of stateless functions.




Thursday, July 10, 2008                                            24
JavaScript Code Usage/
                              Organization Types

                     • Oh so uncool inline events.
                     • Procedural functions at the window level.
                     • Namespaced modules. Essentially just a
                          hash of stateless functions.
                     • GO FULL OO IN JAVASCRIPT!

Thursday, July 10, 2008                                            24
Do not think about DOM elements
                    that have events attached to them,
                  but instead think in terms of JavaScript
                   objects that are instances of classes
                      modeled in your domain which
                               know about:




Thursday, July 10, 2008                                      25
Do not think about DOM elements
                    that have events attached to them,
                  but instead think in terms of JavaScript
                   objects that are instances of classes
                      modeled in your domain which
                               know about:

                          •   The DOM element(s) they represent.




Thursday, July 10, 2008                                            25
Do not think about DOM elements
                    that have events attached to them,
                  but instead think in terms of JavaScript
                   objects that are instances of classes
                      modeled in your domain which
                               know about:

                          •   The DOM element(s) they represent.
                          •   The behavior needed to change the page.




Thursday, July 10, 2008                                                 25
Do not think about DOM elements
                    that have events attached to them,
                  but instead think in terms of JavaScript
                   objects that are instances of classes
                      modeled in your domain which
                               know about:

                          •   The DOM element(s) they represent.
                          •   The behavior needed to change the page.
                          •   The state changes to report to the
                              application server. (with ajax)


Thursday, July 10, 2008                                                 25
Prototype
                             Class
                          Construction
Thursday, July 10, 2008                  26
Prototype Class Construction




Thursday, July 10, 2008                            27
Prototype Class Construction

           • All examples from prototypejs.org




Thursday, July 10, 2008                            27
Prototype Class Construction

           • All examples from prototypejs.org
           • Get very familiar with the whole API
                   http://www.prototypejs.org/api




Thursday, July 10, 2008                             27
Prototype Class Construction

           • All examples from prototypejs.org
           • Get very familiar with the whole API
                   http://www.prototypejs.org/api
           • You must learn! Tips and tricks.
                   http://www.prototypejs.org/learn




Thursday, July 10, 2008                               27
Prototype Class Construction

           • All examples from prototypejs.org
           • Get very familiar with the whole API
                   http://www.prototypejs.org/api
           • You must learn! Tips and tricks.
                   http://www.prototypejs.org/learn
           • Focus on classes and inheritance.
                   http://www.prototypejs.org/learn/class-inheritance

Thursday, July 10, 2008                                                 27
Basic Class Constructor




Thursday, July 10, 2008                             28
http://www.prototypejs.org/learn/class-inheritance




Thursday, July 10, 2008                                                        29
Review



Thursday, July 10, 2008            30
HomeMarks v2.0 Review




Thursday, July 10, 2008                           31
HomeMarks v2.0 Review

               • Total rewrite for rails 2.1




Thursday, July 10, 2008                           31
HomeMarks v2.0 Review

               • Total rewrite for rails 2.1
               • Completely Restful. App focuses solely on the
                          data’s state change. Like an web service.




Thursday, July 10, 2008                                               31
HomeMarks v2.0 Review

               • Total rewrite for rails 2.1
               • Completely Restful. App focuses solely on the
                          data’s state change. Like an web service.
               • Articles on MetaSkills.net


Thursday, July 10, 2008                                               31
http://www.metaskills.net/2008/5/24/the-ajax-head-br-design-pattern




Thursday, July 10, 2008                                                                         32
http://www.metaskills.net/2008/6/18/restful-ajax-with-forgery-protection




Thursday, July 10, 2008                                                                              33
HomeMarks v2.0 Review

               • Total rewrite for rails 2.1
               • Completely Restful. App focuses solely on the
                          data’s state change. Like an web service.
               • Articles on MetaSkills.net


Thursday, July 10, 2008                                               34
HomeMarks v2.0 Review

               • Total rewrite for rails 2.1
               • Completely Restful. App focuses solely on the
                          data’s state change. Like an web service.
               • Articles on MetaSkills.net
               • Focus on these class files in the Github project.

Thursday, July 10, 2008                                               34
http://github.com/metaskills/homemarks/tree/master/public/javascripts/homemarks




Thursday, July 10, 2008                                                                             35
HomeMarks Follow Up




Thursday, July 10, 2008                         36
HomeMarks Follow Up
               •          JS classes split into two virtual domains. A cluster of them are
                          for the site, others for the app. Focus on the application
                          cluster. Includes base, app, page, column, box...




Thursday, July 10, 2008                                                                      36
HomeMarks Follow Up
               •          JS classes split into two virtual domains. A cluster of them are
                          for the site, others for the app. Focus on the application
                          cluster. Includes base, app, page, column, box...
               •          All domain classes like column, box, etc inherit from the
                          HomeMarksApp class. This gives object from these sub classes
                          access to things like 4 things every object needs to know:




Thursday, July 10, 2008                                                                      36
HomeMarks Follow Up
               •          JS classes split into two virtual domains. A cluster of them are
                          for the site, others for the app. Focus on the application
                          cluster. Includes base, app, page, column, box...
               •          All domain classes like column, box, etc inherit from the
                          HomeMarksApp class. This gives object from these sub classes
                          access to things like 4 things every object needs to know:

                            Shared knowledge of DOM elements common to all.




Thursday, July 10, 2008                                                                      36
HomeMarks Follow Up
               •          JS classes split into two virtual domains. A cluster of them are
                          for the site, others for the app. Focus on the application
                          cluster. Includes base, app, page, column, box...
               •          All domain classes like column, box, etc inherit from the
                          HomeMarksApp class. This gives object from these sub classes
                          access to things like 4 things every object needs to know:

                            Shared knowledge of DOM elements common to all.
                            How to communicate to the server with AJAX. This allows
                            the app to have one AJAX observer constructor.




Thursday, July 10, 2008                                                                      36
HomeMarks Follow Up
               •          JS classes split into two virtual domains. A cluster of them are
                          for the site, others for the app. Focus on the application
                          cluster. Includes base, app, page, column, box...
               •          All domain classes like column, box, etc inherit from the
                          HomeMarksApp class. This gives object from these sub classes
                          access to things like 4 things every object needs to know:

                            Shared knowledge of DOM elements common to all.
                            How to communicate to the server with AJAX. This allows
                            the app to have one AJAX observer constructor.
                            A this.flash() function to send dashboard messages.




Thursday, July 10, 2008                                                                      36
HomeMarks Follow Up
               •          JS classes split into two virtual domains. A cluster of them are
                          for the site, others for the app. Focus on the application
                          cluster. Includes base, app, page, column, box...
               •          All domain classes like column, box, etc inherit from the
                          HomeMarksApp class. This gives object from these sub classes
                          access to things like 4 things every object needs to know:

                            Shared knowledge of DOM elements common to all.
                            How to communicate to the server with AJAX. This allows
                            the app to have one AJAX observer constructor.
                            A this.flash() function to send dashboard messages.
                            Access to this.modal() for any fancy modal displays.


Thursday, July 10, 2008                                                                      36

Weitere ähnliche Inhalte

Andere mochten auch

03. Introduccion a JavaScript y JQuery
03. Introduccion a JavaScript y JQuery03. Introduccion a JavaScript y JQuery
03. Introduccion a JavaScript y JQueryDanae Aguilar GuzmĂĄn
 
JavaScript: The prototype Property
JavaScript: The prototype PropertyJavaScript: The prototype Property
JavaScript: The prototype PropertyGuillermo Paz
 
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)raja kvk
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized军 沈
 
JavaScript Prototype and Module Pattern
JavaScript Prototype and Module PatternJavaScript Prototype and Module Pattern
JavaScript Prototype and Module PatternNarendra Sisodiya
 
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScriptPrototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScriptSunny Sharma
 

Andere mochten auch (6)

03. Introduccion a JavaScript y JQuery
03. Introduccion a JavaScript y JQuery03. Introduccion a JavaScript y JQuery
03. Introduccion a JavaScript y JQuery
 
JavaScript: The prototype Property
JavaScript: The prototype PropertyJavaScript: The prototype Property
JavaScript: The prototype Property
 
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized
 
JavaScript Prototype and Module Pattern
JavaScript Prototype and Module PatternJavaScript Prototype and Module Pattern
JavaScript Prototype and Module Pattern
 
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScriptPrototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
 

Ähnlich wie Oo java script class construction

Introduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScriptIntroduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScriptJakob Torp
 
Developing Cocoa Applications with macRuby
Developing Cocoa Applications with macRubyDeveloping Cocoa Applications with macRuby
Developing Cocoa Applications with macRubyBrendan Lim
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object PatternDante Briones
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayChamnap Chhorn
 
Devoxx%202008%20Tutorial
Devoxx%202008%20TutorialDevoxx%202008%20Tutorial
Devoxx%202008%20Tutorialtutorialsruby
 
Devoxx%202008%20Tutorial
Devoxx%202008%20TutorialDevoxx%202008%20Tutorial
Devoxx%202008%20Tutorialtutorialsruby
 
JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011Charles Nutter
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)jeresig
 
JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)jeresig
 
JavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat SheetJavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat SheetHDR1001
 
Java EE Servlet JSP Tutorial- Cookbook 1
Java EE Servlet JSP Tutorial- Cookbook 1Java EE Servlet JSP Tutorial- Cookbook 1
Java EE Servlet JSP Tutorial- Cookbook 1billdigman
 
JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)jeresig
 
Jython 2.7 and techniques for integrating with Java - Frank Wierzbicki
Jython 2.7 and techniques for integrating with Java - Frank WierzbickiJython 2.7 and techniques for integrating with Java - Frank Wierzbicki
Jython 2.7 and techniques for integrating with Java - Frank Wierzbickifwierzbicki
 

Ähnlich wie Oo java script class construction (20)

FreshAir2008
FreshAir2008FreshAir2008
FreshAir2008
 
FreshAir2008
FreshAir2008FreshAir2008
FreshAir2008
 
Introduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScriptIntroduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScript
 
Java to scala
Java to scalaJava to scala
Java to scala
 
Reef - ESUG 2010
Reef - ESUG 2010Reef - ESUG 2010
Reef - ESUG 2010
 
Developing Cocoa Applications with macRuby
Developing Cocoa Applications with macRubyDeveloping Cocoa Applications with macRuby
Developing Cocoa Applications with macRuby
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
 
Devoxx%202008%20Tutorial
Devoxx%202008%20TutorialDevoxx%202008%20Tutorial
Devoxx%202008%20Tutorial
 
Devoxx%202008%20Tutorial
Devoxx%202008%20TutorialDevoxx%202008%20Tutorial
Devoxx%202008%20Tutorial
 
JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
 
JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)
 
JavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat SheetJavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat Sheet
 
Java EE Servlet JSP Tutorial- Cookbook 1
Java EE Servlet JSP Tutorial- Cookbook 1Java EE Servlet JSP Tutorial- Cookbook 1
Java EE Servlet JSP Tutorial- Cookbook 1
 
JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)
 
Welcome to React.pptx
Welcome to React.pptxWelcome to React.pptx
Welcome to React.pptx
 
GWT-Basics
GWT-BasicsGWT-Basics
GWT-Basics
 
GWT-Basics
GWT-BasicsGWT-Basics
GWT-Basics
 
Jython 2.7 and techniques for integrating with Java - Frank Wierzbicki
Jython 2.7 and techniques for integrating with Java - Frank WierzbickiJython 2.7 and techniques for integrating with Java - Frank Wierzbicki
Jython 2.7 and techniques for integrating with Java - Frank Wierzbicki
 

Mehr von Ken Collins

Secrets of the asset pipeline
Secrets of the asset pipelineSecrets of the asset pipeline
Secrets of the asset pipelineKen Collins
 
Ruby struct
Ruby structRuby struct
Ruby structKen Collins
 
Dominion Enterprises _H@<k@th0n_
Dominion Enterprises _H@<k@th0n_Dominion Enterprises _H@<k@th0n_
Dominion Enterprises _H@<k@th0n_Ken Collins
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainKen Collins
 
Memcached Presentation @757rb
Memcached Presentation @757rbMemcached Presentation @757rb
Memcached Presentation @757rbKen Collins
 
Synchronizing Core Data With Rails
Synchronizing Core Data With RailsSynchronizing Core Data With Rails
Synchronizing Core Data With RailsKen Collins
 

Mehr von Ken Collins (7)

Secrets of the asset pipeline
Secrets of the asset pipelineSecrets of the asset pipeline
Secrets of the asset pipeline
 
Ruby struct
Ruby structRuby struct
Ruby struct
 
Dominion Enterprises _H@<k@th0n_
Dominion Enterprises _H@<k@th0n_Dominion Enterprises _H@<k@th0n_
Dominion Enterprises _H@<k@th0n_
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own Domain
 
Memcached Presentation @757rb
Memcached Presentation @757rbMemcached Presentation @757rb
Memcached Presentation @757rb
 
Tool Time
Tool TimeTool Time
Tool Time
 
Synchronizing Core Data With Rails
Synchronizing Core Data With RailsSynchronizing Core Data With Rails
Synchronizing Core Data With Rails
 

KĂźrzlich hochgeladen

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

KĂźrzlich hochgeladen (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

Oo java script class construction

  • 1. OO JavaScript Class Construction Using The Prototype JavaScript Framework July 8th 2008 Ken Collins http://metaskills.net/ Thursday, July 10, 2008 1
  • 3. Topic Overview • Basic JavaScript Refresher Thursday, July 10, 2008 2
  • 4. Topic Overview • Basic JavaScript Refresher • The Ruby Object Model Thursday, July 10, 2008 2
  • 5. Topic Overview • Basic JavaScript Refresher • The Ruby Object Model • JavaScript Code Usage/Organization Types Thursday, July 10, 2008 2
  • 6. Topic Overview • Basic JavaScript Refresher • The Ruby Object Model • JavaScript Code Usage/Organization Types • Prototype Class Construction Thursday, July 10, 2008 2
  • 7. Topic Overview • Basic JavaScript Refresher • The Ruby Object Model • JavaScript Code Usage/Organization Types • Prototype Class Construction • Review HomeMarks v2.0 Thursday, July 10, 2008 2
  • 8. Basic JavaScript Refresher Thursday, July 10, 2008 3
  • 10. Basic JavaScript Refresher • JavaScript is a prototype-based language. Thursday, July 10, 2008 4
  • 11. Prototype-based programming is a style of object-oriented programming in which classes are not present, and behavior reuse (known as inheritance in class-based languages) is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as class- less, prototype-oriented or instance-based programming. http://en.wikipedia.org/wiki/Prototype-based_programming Thursday, July 10, 2008 5
  • 12. Basic JavaScript Refresher • JavaScript is a prototype-based language. Thursday, July 10, 2008 6
  • 13. Basic JavaScript Refresher • JavaScript is a prototype-based language. • JavaScript objects are best thought about as hashes. New values and even functions can just be tacked on. Thursday, July 10, 2008 6
  • 16. Basic JavaScript Refresher • JavaScript is a prototype-based language. • JavaScript objects are best thought about as hashes. New values and even functions can just be tacked on. Thursday, July 10, 2008 8
  • 17. Basic JavaScript Refresher • JavaScript is a prototype-based language. • JavaScript objects are best thought about as hashes. New values and even functions can just be tacked on. • Get rebug and use console.log() liberally! Thursday, July 10, 2008 8
  • 20. Basic JavaScript Refresher • JavaScript is a prototype-based language. • JavaScript objects are best thought about as hashes. New values and even functions can just be tacked on. • Get rebug and use console.log() liberally! Thursday, July 10, 2008 11
  • 21. Basic JavaScript Refresher • JavaScript is a prototype-based language. • JavaScript objects are best thought about as hashes. New values and even functions can just be tacked on. • Get rebug and use console.log() liberally! • Remember, that functions are objects too. With non-strict argument options. Thursday, July 10, 2008 11
  • 23. Basic JavaScript Refresher • JavaScript is a prototype-based language. • JavaScript objects are best thought about as hashes. New values and even functions can just be tacked on. • Get rebug and use console.log() liberally! • Remember, that functions are objects too. With non-strict argument options. • Knowing what “this” is can save you lots of debugging and headaches. (another topic) Thursday, July 10, 2008 13
  • 24. The Ruby Object Model Knowing Ruby’s object model will help you with Prototype’s class construction and how it mimics inheritance and mixins. Thursday, July 10, 2008 14
  • 25. Inheritance in Ruby Thursday, July 10, 2008 15
  • 26. Module Mixins in Ruby Thursday, July 10, 2008 16
  • 27. Prototyping in Ruby Thursday, July 10, 2008 17
  • 29. JavaScript Code Usage/Organization Types Thursday, July 10, 2008 19
  • 30. JavaScript Code Usage/ Organization Types Thursday, July 10, 2008 20
  • 31. JavaScript Code Usage/ Organization Types • Oh so uncool inline events. • Procedural functions at the window level. Thursday, July 10, 2008 20
  • 32. Inheritance in Ruby Thursday, July 10, 2008 21
  • 33. JavaScript Code Usage/ Organization Types • Oh so uncool inline events. • Procedural functions at the window level. Thursday, July 10, 2008 22
  • 34. JavaScript Code Usage/ Organization Types • Oh so uncool inline events. • Procedural functions at the window level. • Namespaced modules. Essentially just a hash of stateless functions. Thursday, July 10, 2008 22
  • 35. Inheritance in Ruby Thursday, July 10, 2008 23
  • 36. JavaScript Code Usage/ Organization Types • Oh so uncool inline events. • Procedural functions at the window level. • Namespaced modules. Essentially just a hash of stateless functions. Thursday, July 10, 2008 24
  • 37. JavaScript Code Usage/ Organization Types • Oh so uncool inline events. • Procedural functions at the window level. • Namespaced modules. Essentially just a hash of stateless functions. • GO FULL OO IN JAVASCRIPT! Thursday, July 10, 2008 24
  • 38. Do not think about DOM elements that have events attached to them, but instead think in terms of JavaScript objects that are instances of classes modeled in your domain which know about: Thursday, July 10, 2008 25
  • 39. Do not think about DOM elements that have events attached to them, but instead think in terms of JavaScript objects that are instances of classes modeled in your domain which know about: • The DOM element(s) they represent. Thursday, July 10, 2008 25
  • 40. Do not think about DOM elements that have events attached to them, but instead think in terms of JavaScript objects that are instances of classes modeled in your domain which know about: • The DOM element(s) they represent. • The behavior needed to change the page. Thursday, July 10, 2008 25
  • 41. Do not think about DOM elements that have events attached to them, but instead think in terms of JavaScript objects that are instances of classes modeled in your domain which know about: • The DOM element(s) they represent. • The behavior needed to change the page. • The state changes to report to the application server. (with ajax) Thursday, July 10, 2008 25
  • 42. Prototype Class Construction Thursday, July 10, 2008 26
  • 44. Prototype Class Construction • All examples from prototypejs.org Thursday, July 10, 2008 27
  • 45. Prototype Class Construction • All examples from prototypejs.org • Get very familiar with the whole API http://www.prototypejs.org/api Thursday, July 10, 2008 27
  • 46. Prototype Class Construction • All examples from prototypejs.org • Get very familiar with the whole API http://www.prototypejs.org/api • You must learn! Tips and tricks. http://www.prototypejs.org/learn Thursday, July 10, 2008 27
  • 47. Prototype Class Construction • All examples from prototypejs.org • Get very familiar with the whole API http://www.prototypejs.org/api • You must learn! Tips and tricks. http://www.prototypejs.org/learn • Focus on classes and inheritance. http://www.prototypejs.org/learn/class-inheritance Thursday, July 10, 2008 27
  • 52. HomeMarks v2.0 Review • Total rewrite for rails 2.1 Thursday, July 10, 2008 31
  • 53. HomeMarks v2.0 Review • Total rewrite for rails 2.1 • Completely Restful. App focuses solely on the data’s state change. Like an web service. Thursday, July 10, 2008 31
  • 54. HomeMarks v2.0 Review • Total rewrite for rails 2.1 • Completely Restful. App focuses solely on the data’s state change. Like an web service. • Articles on MetaSkills.net Thursday, July 10, 2008 31
  • 57. HomeMarks v2.0 Review • Total rewrite for rails 2.1 • Completely Restful. App focuses solely on the data’s state change. Like an web service. • Articles on MetaSkills.net Thursday, July 10, 2008 34
  • 58. HomeMarks v2.0 Review • Total rewrite for rails 2.1 • Completely Restful. App focuses solely on the data’s state change. Like an web service. • Articles on MetaSkills.net • Focus on these class les in the Github project. Thursday, July 10, 2008 34
  • 60. HomeMarks Follow Up Thursday, July 10, 2008 36
  • 61. HomeMarks Follow Up • JS classes split into two virtual domains. A cluster of them are for the site, others for the app. Focus on the application cluster. Includes base, app, page, column, box... Thursday, July 10, 2008 36
  • 62. HomeMarks Follow Up • JS classes split into two virtual domains. A cluster of them are for the site, others for the app. Focus on the application cluster. Includes base, app, page, column, box... • All domain classes like column, box, etc inherit from the HomeMarksApp class. This gives object from these sub classes access to things like 4 things every object needs to know: Thursday, July 10, 2008 36
  • 63. HomeMarks Follow Up • JS classes split into two virtual domains. A cluster of them are for the site, others for the app. Focus on the application cluster. Includes base, app, page, column, box... • All domain classes like column, box, etc inherit from the HomeMarksApp class. This gives object from these sub classes access to things like 4 things every object needs to know: Shared knowledge of DOM elements common to all. Thursday, July 10, 2008 36
  • 64. HomeMarks Follow Up • JS classes split into two virtual domains. A cluster of them are for the site, others for the app. Focus on the application cluster. Includes base, app, page, column, box... • All domain classes like column, box, etc inherit from the HomeMarksApp class. This gives object from these sub classes access to things like 4 things every object needs to know: Shared knowledge of DOM elements common to all. How to communicate to the server with AJAX. This allows the app to have one AJAX observer constructor. Thursday, July 10, 2008 36
  • 65. HomeMarks Follow Up • JS classes split into two virtual domains. A cluster of them are for the site, others for the app. Focus on the application cluster. Includes base, app, page, column, box... • All domain classes like column, box, etc inherit from the HomeMarksApp class. This gives object from these sub classes access to things like 4 things every object needs to know: Shared knowledge of DOM elements common to all. How to communicate to the server with AJAX. This allows the app to have one AJAX observer constructor. A this.flash() function to send dashboard messages. Thursday, July 10, 2008 36
  • 66. HomeMarks Follow Up • JS classes split into two virtual domains. A cluster of them are for the site, others for the app. Focus on the application cluster. Includes base, app, page, column, box... • All domain classes like column, box, etc inherit from the HomeMarksApp class. This gives object from these sub classes access to things like 4 things every object needs to know: Shared knowledge of DOM elements common to all. How to communicate to the server with AJAX. This allows the app to have one AJAX observer constructor. A this.flash() function to send dashboard messages. Access to this.modal() for any fancy modal displays. Thursday, July 10, 2008 36