SlideShare a Scribd company logo
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://getfirebug.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

More Related Content

Viewers also liked

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
 

Viewers also liked (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
 

Similar to 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
 

Similar to 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
 

More from Ken Collins

Secrets of the asset pipeline
Secrets of the asset pipelineSecrets of the asset pipeline
Secrets of the asset pipelineKen 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
 

More from 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
 

Recently uploaded

Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoTAnalytics
 
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»QADay
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaRTTS
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesThousandEyes
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 

Recently uploaded (20)

Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 

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 firebug 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 firebug 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 firebug 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 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
  • 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 files 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