SlideShare a Scribd company logo
1 of 177
Download to read offline
Enterprise JavaScript
                            Session 2 - Building Applications




Wednesday, November 7, 12
Hi, I’m Troy




Wednesday, November 7, 12
Hi, I’m Troy
                   • Developing software Since 1979
                   • Initially Game Software in Assembly (6502
                            and x86)
                   • Currently JavaScript, C#, Java, Objective-C
                   • rockncoder@gmail.com


Wednesday, November 7, 12
jssaturday.com
                            Nov. 10th, Long Beach Convention
                                          Center
                             Discount code: RiaConsultingLLC
                                        Save $65!!!



Wednesday, November 7, 12
Today’s Agenda




Wednesday, November 7, 12
Today’s Agenda
                   • Namespacing




Wednesday, November 7, 12
Today’s Agenda
                   • Namespacing
                   • Design Patterns




Wednesday, November 7, 12
Today’s Agenda
                   • Namespacing
                   • Design Patterns
                   • Performance




Wednesday, November 7, 12
Today’s Agenda
                   • Namespacing
                   • Design Patterns
                   • Performance
                   • Debugging



Wednesday, November 7, 12
Namespacing



Wednesday, November 7, 12
Namespacing
                      Namespacing is a technique employed to
                      avoid collisions with other objects or
                      variables in the global namespace. They're
                      also extremely useful for helping organize
                      blocks of functionality in your application
                      into easily manageable groups that can be
                      uniquely identified.
                      -- Addy Osmani


Wednesday, November 7, 12
Hands-on Exercise




Wednesday, November 7, 12
Hands-on Exercise
                   • In jsFiddle.net




Wednesday, November 7, 12
Hands-on Exercise
                   • In jsFiddle.net
                   • Create a global var named “myApp”




Wednesday, November 7, 12
Hands-on Exercise
                   • In jsFiddle.net
                   • Create a global var named “myApp”
                   • If it has been defined already, make it equal
                            to its previous instance




Wednesday, November 7, 12
Hands-on Exercise
                   • In jsFiddle.net
                   • Create a global var named “myApp”
                   • If it has been defined already, make it equal
                            to its previous instance
                   • If it hasn’t been defined, make it equal to an
                            empty object literal



Wednesday, November 7, 12
Answers




Wednesday, November 7, 12
Answers
                   1. var myApp = myApp || {};




Wednesday, November 7, 12
Answers
                   1. var myApp = myApp || {};
                   2. if(!myApp) myApp = {};




Wednesday, November 7, 12
Answers
                   1. var myApp = myApp || {};
                   2. if(!myApp) myApp = {};
                   3. myApp || (myApp = {});




Wednesday, November 7, 12
Answers
                   1. var myApp = myApp || {};
                   2. if(!myApp) myApp = {};
                   3. myApp || (myApp = {});
                   4. var myApp = myApp === undefined ? {} :
                      myApp;




Wednesday, November 7, 12
Namespaces




Wednesday, November 7, 12
Namespaces
                   • Single global variables




Wednesday, November 7, 12
Namespaces
                   • Single global variables
                   • Object literal notation




Wednesday, November 7, 12
Namespaces
                   • Single global variables
                   • Object literal notation
                   • Nested namespacing




Wednesday, November 7, 12
Namespaces
                   • Single global variables
                   • Object literal notation
                   • Nested namespacing
                   • Immediately-Invoked Function Expressions



Wednesday, November 7, 12
Namespaces
                   • Single global variables
                   • Object literal notation
                   • Nested namespacing
                   • Immediately-Invoked Function Expressions
                   • Namespace Injection


Wednesday, November 7, 12
Single Global Variable




Wednesday, November 7, 12
Single Global Variable
               • The entire application goes into a single
                      global object, usually a function




Wednesday, November 7, 12
Single Global Variable
               • The entire application goes into a single
                      global object, usually a function
               • An object literal is returned by the function




Wednesday, November 7, 12
Single Global Variable
               • The entire application goes into a single
                      global object, usually a function
               • An object literal is returned by the function
               • Not well suited for team development since
                      not easily decomposed




Wednesday, November 7, 12
Single Global Variable
                      var myApplication = (function(){
                        function() {
                           /*...*/
                        },
                        return{
                           /*...*/
                        };
                      })();




Wednesday, November 7, 12
Object Literal Notation




Wednesday, November 7, 12
Object Literal Notation
                   • Doesn’t pollute the global namespace




Wednesday, November 7, 12
Object Literal Notation
                   • Doesn’t pollute the global namespace
                   • Assist in organizing code into logical parts




Wednesday, November 7, 12
Object Literal Notation
                   • Doesn’t pollute the global namespace
                   • Assist in organizing code into logical parts
                   • Easy to read




Wednesday, November 7, 12
Nested Namespacing




Wednesday, November 7, 12
Nested Namespacing
                   • An extension of object literal notiation




Wednesday, November 7, 12
Nested Namespacing
                   • An extension of object literal notiation
                   • Even if a namespace already exists, unlikely
                            that the children do




Wednesday, November 7, 12
Nested Namespacing
                   • An extension of object literal notiation
                   • Even if a namespace already exists, unlikely
                            that the children do
                   • Used extensively by JavaScript API vendors
                            like Yahoo and Google




Wednesday, November 7, 12
Nested Namespacing
                   • An extension of object literal notiation
                   • Even if a namespace already exists, unlikely
                            that the children do
                   • Used extensively by JavaScript API vendors
                            like Yahoo and Google
                   • Negligible performance ding

Wednesday, November 7, 12
Immediately-Invoked
                      Function Expressions




Wednesday, November 7, 12
Immediately-Invoked
                      Function Expressions
                   • Also known as “iffy”




Wednesday, November 7, 12
Immediately-Invoked
                      Function Expressions
                   • Also known as “iffy”
                   • An unnamed function which is immediately
                            invoked after it’s been defined




Wednesday, November 7, 12
Immediately-Invoked
                      Function Expressions
                   • Also known as “iffy”
                   • An unnamed function which is immediately
                            invoked after it’s been defined
                   • Allows for information hiding



Wednesday, November 7, 12
Immediately-Invoked
                      Function Expressions
                   • Also known as “iffy”
                   • An unnamed function which is immediately
                            invoked after it’s been defined
                   • Allows for information hiding
                   • Improves minification results


Wednesday, November 7, 12
Namespace Injection




Wednesday, November 7, 12
Namespace Injection
                   • A variation of the IIFE




Wednesday, November 7, 12
Namespace Injection
                   • A variation of the IIFE
                   • Methods and properties get injected for a
                            specific namespace




Wednesday, November 7, 12
Namespace Injection
                   • A variation of the IIFE
                   • Methods and properties get injected for a
                            specific namespace
                   • A bit cumbersome



Wednesday, November 7, 12
Namespaces




Wednesday, November 7, 12
Namespaces
                   • Most of my current code uses Nested
                            Namespacing




Wednesday, November 7, 12
Namespaces
                   • Most of my current code uses Nested
                            Namespacing
                   • My newest code uses IIFE




Wednesday, November 7, 12
Design Patterns



Wednesday, November 7, 12
Design Patterns




Wednesday, November 7, 12
Design Patterns
                   • Singleton




Wednesday, November 7, 12
Design Patterns
                   • Singleton
                   • Chaining




Wednesday, November 7, 12
Design Patterns
                   • Singleton
                   • Chaining
                   • Observer




Wednesday, November 7, 12
Design Patterns
                   • Singleton
                   • Chaining
                   • Observer
                   • Hands-on Exercise



Wednesday, November 7, 12
Singleton
                      The singleton pattern is a design pattern that
                      restricts the instantiation of a class to one
                      object.




Wednesday, November 7, 12
When to Use a Singleton




Wednesday, November 7, 12
When to Use a Singleton
                   • For namespacing or modularizing code, it
                            should be used as often as possible




Wednesday, November 7, 12
When to Use a Singleton
                   • For namespacing or modularizing code, it
                            should be used as often as possible
                   • In simple projects, a singleton can be used a
                            a namespace




Wednesday, November 7, 12
When to Use a Singleton
                   • For namespacing or modularizing code, it
                            should be used as often as possible
                   • In simple projects, a singleton can be used a
                            a namespace
                   • In larger projects, it can be used to group
                            related code together




Wednesday, November 7, 12
Chaining
                      Method chaining, also known as named
                      parameter idiom, is a common technique for
                      invoking multiple method calls in object-
                      oriented programming languages.




Wednesday, November 7, 12
Chaining
                      Not really a design pattern, more of a syntax
                      hack, but its extensive use in JavaScript and
                      JavaScript libraries requires explanation.




Wednesday, November 7, 12
Chaining




Wednesday, November 7, 12
Chaining
                   • There are generally two types of methods:




Wednesday, November 7, 12
Chaining
                   • There are generally two types of methods:
                   • Accessors - return a value




Wednesday, November 7, 12
Chaining
                   • There are generally two types of methods:
                   • Accessors - return a value
                   • Mutators - modify a property on the object
                            and return “this” to enable chaining




Wednesday, November 7, 12
Observer
                      The observer pattern is a software design
                      pattern in which an object, called the
                      subject, maintains a list of its dependents,
                      called observers, and notifies them
                      automatically of any state changes, usually by
                      calling one of their methods. It is mainly used
                      to implement distributed event handling
                      systems.


Wednesday, November 7, 12
Observer




Wednesday, November 7, 12
Observer
                   • Consist of three main components:




Wednesday, November 7, 12
Observer
                   • Consist of three main components:
                   • The Observer




Wednesday, November 7, 12
Observer
                   • Consist of three main components:
                   • The Observer
                   • The Observer List




Wednesday, November 7, 12
Observer
                   • Consist of three main components:
                   • The Observer
                   • The Observer List
                   • The Subject



Wednesday, November 7, 12
Hands-on Exercise




Wednesday, November 7, 12
Hands-on Exercise
                   • http://jsfiddle.net/rockncoder/FkDRV/2/




Wednesday, November 7, 12
Hands-on Exercise
                   • http://jsfiddle.net/rockncoder/FkDRV/2/
                   • Hook an event handler to the “Click Me”
                            button




Wednesday, November 7, 12
Hands-on Exercise
                   • http://jsfiddle.net/rockncoder/FkDRV/2/
                   • Hook an event handler to the “Click Me”
                            button
                   • Have it some how cause the “log.me” event



Wednesday, November 7, 12
Hands-on Exercise
                   • http://jsfiddle.net/rockncoder/FkDRV/2/
                   • Hook an event handler to the “Click Me”
                            button
                   • Have it some how cause the “log.me” event
                   • Remember to pass a message, (msg)


Wednesday, November 7, 12
Performance



Wednesday, November 7, 12
Performance




Wednesday, November 7, 12
Performance
                   • Big O-Notation




Wednesday, November 7, 12
Performance
                   • Big O-Notation
                   • Measuring Performance




Wednesday, November 7, 12
Performance
                   • Big O-Notation
                   • Measuring Performance
                   • 5 Performance Tips




Wednesday, November 7, 12
Performance
                   • Big O-Notation
                   • Measuring Performance
                   • 5 Performance Tips
                   • Hands-on Exercise



Wednesday, November 7, 12
We should forget about small efficiencies, say
               about 97% of the time: premature optimization
               is the root of all evil.Yet we should not pass up
                     our opportunities in that critical 3%.
                                     D. Knuth




Wednesday, November 7, 12
Big O Notation



Wednesday, November 7, 12
Big O Notation




Wednesday, November 7, 12
Big O Notation
                   • O(1), Constant




Wednesday, November 7, 12
Big O Notation
                   • O(1), Constant
                   • O(n), Linear




Wednesday, November 7, 12
Big O Notation
                   • O(1), Constant
                   • O(n), Linear
                   • O(n ^ 2), Quadratic




Wednesday, November 7, 12
Big O Notation
                   • O(1), Constant
                   • O(n), Linear
                   • O(n ^ 2), Quadratic
                   • O(2 ^ n), Exponential



Wednesday, November 7, 12
Big O Notation
                   • O(1), Constant
                   • O(n), Linear
                   • O(n ^ 2), Quadratic
                   • O(2 ^ n), Exponential
                   • O(n!), Factorial


Wednesday, November 7, 12
Measuring Performance




Wednesday, November 7, 12
Measuring Performance
                   • JavaScript’s includes a Date object




Wednesday, November 7, 12
Measuring Performance
                   • JavaScript’s includes a Date object
                   • Date.getTime() measures time in
                            milliseconds




Wednesday, November 7, 12
Measuring Performance
                   • JavaScript’s includes a Date object
                   • Date.getTime() measures time in
                            milliseconds
                   • Resolution is not fine enough so we do
                            things multiple times




Wednesday, November 7, 12
Measuring Performance
                      /* A simple performance measurer */
                      var elapsedTime,
                          startTime = new Date().getTime();

                      /* Do some operations */

                      elapsedTime = new Date().getTime() -
                      startTime;




Wednesday, November 7, 12
5 Performance Tips



Wednesday, November 7, 12
Tip #5
                            Use as few files as
                                possible


Wednesday, November 7, 12
Use as few files as
                                possible




Wednesday, November 7, 12
Use as few files as
                                possible
                   • Browser can load multiple files at a time




Wednesday, November 7, 12
Use as few files as
                                possible
                   • Browser can load multiple files at a time
                   • But only one JS file at a time




Wednesday, November 7, 12
Use as few files as
                                possible
                   • Browser can load multiple files at a time
                   • But only one JS file at a time
                   • Concatenate multiple JS file into one




Wednesday, November 7, 12
Use as few files as
                                possible
                   • Browser can load multiple files at a time
                   • But only one JS file at a time
                   • Concatenate multiple JS file into one
                   • Compress JS files



Wednesday, November 7, 12
Use as few files as
                                possible
                   • Browser can load multiple files at a time
                   • But only one JS file at a time
                   • Concatenate multiple JS file into one
                   • Compress JS files
                   • Prefer JS at the bottom of the HTML file


Wednesday, November 7, 12
Tip #4
                        Prefer local variables


Wednesday, November 7, 12
Prefer local variables




Wednesday, November 7, 12
Prefer local variables
                   • Variables in scope found quicker




Wednesday, November 7, 12
Prefer local variables
                   • Variables in scope found quicker
                   • JS search local scope, then global




Wednesday, November 7, 12
Prefer local variables
                   • Variables in scope found quicker
                   • JS search local scope, then global
                   • with creates a new scope level ahead of
                            local




Wednesday, November 7, 12
Prefer local variables
                   • Variables in scope found quicker
                   • JS search local scope, then global
                   • with creates a new scope level ahead of
                            local
                   • closures also create new scope level


Wednesday, November 7, 12
Global vs. Local Demo



Wednesday, November 7, 12
Prefer local variables
                   • Property chains similar to var scoping
                   • Objects closer in the chain found quicker




Wednesday, November 7, 12
Properties Demo



Wednesday, November 7, 12
Tip #3
                 Reduce the work done
                       in loops


Wednesday, November 7, 12
Reduce the work done
                       in loops




Wednesday, November 7, 12
Reduce the work done
                       in loops
                   • No real speed difference between: for, while
                            and do_while




Wednesday, November 7, 12
Reduce the work done
                       in loops
                   • No real speed difference between: for, while
                            and do_while
                   • Avoid for_in




Wednesday, November 7, 12
Reduce the work done
                       in loops
                   • No real speed difference between: for, while
                            and do_while
                   • Avoid for_in
                   • Watch library based for_each



Wednesday, November 7, 12
Loop Demos



Wednesday, November 7, 12
Tip #2
                            Learn jQuery


Wednesday, November 7, 12
Learn jQuery




Wednesday, November 7, 12
Learn jQuery
                   • Know what jQuery does




Wednesday, November 7, 12
Learn jQuery
                   • Know what jQuery does
                   • Be sure to evaluate its use




Wednesday, November 7, 12
Learn jQuery
                   • Know what jQuery does
                   • Be sure to evaluate its use
                   • Cache the results of jQuery selectors




Wednesday, November 7, 12
jQuery Demo



Wednesday, November 7, 12
Tip #1
                            Avoid the DOM


Wednesday, November 7, 12
Avoid the DOM




Wednesday, November 7, 12
Avoid the DOM
                   • The DOM is REALLY Slow




Wednesday, November 7, 12
Avoid the DOM
                   • The DOM is REALLY Slow
                   • Avoid accessing it when possible




Wednesday, November 7, 12
Avoid the DOM
                   • The DOM is REALLY Slow
                   • Avoid accessing it when possible
                   • Do work offline then update DOM




Wednesday, November 7, 12
DOM Access Demos



Wednesday, November 7, 12
Hands-on Exercise




Wednesday, November 7, 12
Hands-on Exercise
                      http://jsfiddle.net/rockncoder/HDWRb/4/




Wednesday, November 7, 12
Hands-on Exercise
                      http://jsfiddle.net/rockncoder/HDWRb/4/
                      Run the fiddle




Wednesday, November 7, 12
Hands-on Exercise
                      http://jsfiddle.net/rockncoder/HDWRb/4/
                      Run the fiddle
                      Note the execution time




Wednesday, November 7, 12
Hands-on Exercise
                      http://jsfiddle.net/rockncoder/HDWRb/4/
                      Run the fiddle
                      Note the execution time
                      Improve the time




Wednesday, November 7, 12
Hands-on Exercise
                      http://jsfiddle.net/rockncoder/HDWRb/4/
                      Run the fiddle
                      Note the execution time
                      Improve the time
                      Have a question? Call me over




Wednesday, November 7, 12
Debugging




Wednesday, November 7, 12
Debugging
                   • Chrome Developer Tools




Wednesday, November 7, 12
Debugging
                   • Chrome Developer Tools
                   • Safari Remote Debugging




Wednesday, November 7, 12
Debugging
                   • Chrome Developer Tools
                   • Safari Remote Debugging
                   • Fiddler2




Wednesday, November 7, 12
Debugging
                   • Chrome Developer Tools
                   • Safari Remote Debugging
                   • Fiddler2
                   • Proxying an iPad



Wednesday, November 7, 12
Debugging
                   • Chrome Developer Tools
                   • Safari Remote Debugging
                   • Fiddler2
                   • Proxying an iPad
                   • Hands-on Exercise: Fiddler


Wednesday, November 7, 12
Chrome Developer Tools




Wednesday, November 7, 12
Chrome Developer Tools

                   • ctrl-shift-J brings up the console




Wednesday, November 7, 12
Chrome Developer Tools

                   • ctrl-shift-J brings up the console
                   • View HTML




Wednesday, November 7, 12
Chrome Developer Tools

                   • ctrl-shift-J brings up the console
                   • View HTML
                   • View/Modify Source




Wednesday, November 7, 12
Chrome Developer Tools

                   • ctrl-shift-J brings up the console
                   • View HTML
                   • View/Modify Source
                   • Set breakpoints



Wednesday, November 7, 12
Safari Remote Debugging




Wednesday, November 7, 12
Safari Remote Debugging

                   • Settings > Safari > Advanced




Wednesday, November 7, 12
Safari Remote Debugging

                   • Settings > Safari > Advanced
                   • Web Inspector = ON




Wednesday, November 7, 12
Safari Remote Debugging

                   • Settings > Safari > Advanced
                   • Web Inspector = ON
                   • Safari > Develop > iPad > website




Wednesday, November 7, 12
Safari Remote Debugging

                   • Settings > Safari > Advanced
                   • Web Inspector = ON
                   • Safari > Develop > iPad > website
                   • Similar to using Chrome



Wednesday, November 7, 12
Fiddler2




Wednesday, November 7, 12
Fiddler2
                   • http://www.fiddler2.com/fiddler2/




Wednesday, November 7, 12
Fiddler2
                   • http://www.fiddler2.com/fiddler2/
                   • Web Debugging Proxy




Wednesday, November 7, 12
Fiddler2
                   • http://www.fiddler2.com/fiddler2/
                   • Web Debugging Proxy
                   • View Web Traffic




Wednesday, November 7, 12
Fiddler2
                   • http://www.fiddler2.com/fiddler2/
                   • Web Debugging Proxy
                   • View Web Traffic
                   • Filter Web Traffic



Wednesday, November 7, 12
Fiddler2
                   • http://www.fiddler2.com/fiddler2/
                   • Web Debugging Proxy
                   • View Web Traffic
                   • Filter Web Traffic
                   • Inspect Requests


Wednesday, November 7, 12
Fiddler2
                   • http://www.fiddler2.com/fiddler2/
                   • Web Debugging Proxy
                   • View Web Traffic
                   • Filter Web Traffic
                   • Inspect Requests
                   • Inspect Responses

Wednesday, November 7, 12
Proxying an iPad




Wednesday, November 7, 12
Proxying an iPad
                   • Tools > Fiddler Options > Connections




Wednesday, November 7, 12
Proxying an iPad
                   • Tools > Fiddler Options > Connections
                   • Wi-Fi > (right arrow) > HTTP Proxy




Wednesday, November 7, 12
Proxying an iPad
                   • Tools > Fiddler Options > Connections
                   • Wi-Fi > (right arrow) > HTTP Proxy
                   • Set Server & Port




Wednesday, November 7, 12
Proxying an iPad
                   • Tools > Fiddler Options > Connections
                   • Wi-Fi > (right arrow) > HTTP Proxy
                   • Set Server & Port
                   • Unfortunately Proxying an Android device
                            is not as easy




Wednesday, November 7, 12
Hands-on Exercise




Wednesday, November 7, 12
Hands-on Exercise
                   • Twitter’s Search API is Open
                   • The URL is http://search.twitter.com/
                            search.json?q={subject}
                   • Using Fiddler make a request to Twitter
                            about “sandy”
                   • Use the JSON view to inspect the results

Wednesday, November 7, 12
The Code is Online


         https://github.com/Rockncoder/EnterpriseJavaScript




Wednesday, November 7, 12
Summary




Wednesday, November 7, 12
Summary
                   • Namespacing




Wednesday, November 7, 12
Summary
                   • Namespacing
                   • Design Patterns




Wednesday, November 7, 12
Summary
                   • Namespacing
                   • Design Patterns
                   • Performance




Wednesday, November 7, 12
Summary
                   • Namespacing
                   • Design Patterns
                   • Performance
                   • Debugging



Wednesday, November 7, 12

More Related Content

Similar to Enterprise javascriptsession2

Enterprise javascriptsession3
Enterprise javascriptsession3Enterprise javascriptsession3
Enterprise javascriptsession3Troy Miles
 
Enterprise javascriptsession1
Enterprise javascriptsession1Enterprise javascriptsession1
Enterprise javascriptsession1Troy Miles
 
Morning with MongoDB Paris 2012 - MongoDB Basic Concepts
Morning with MongoDB Paris 2012 - MongoDB Basic ConceptsMorning with MongoDB Paris 2012 - MongoDB Basic Concepts
Morning with MongoDB Paris 2012 - MongoDB Basic ConceptsMongoDB
 
JavaScript: The prototype Property
JavaScript: The prototype PropertyJavaScript: The prototype Property
JavaScript: The prototype PropertyGuillermo Paz
 
Why not to use Rails? (actually it's when not to use Rails)
Why not to use Rails? (actually it's when not to use Rails)Why not to use Rails? (actually it's when not to use Rails)
Why not to use Rails? (actually it's when not to use Rails)Arik Fraimovich
 
Software Libraries And Numbers
Software Libraries And NumbersSoftware Libraries And Numbers
Software Libraries And NumbersRobert Reiz
 
JS-Everywhere - LocalStorage Hands-on
JS-Everywhere - LocalStorage Hands-onJS-Everywhere - LocalStorage Hands-on
JS-Everywhere - LocalStorage Hands-onBrice Argenson
 
Performance test - YaJUG Octobre 2012
Performance test - YaJUG Octobre 2012Performance test - YaJUG Octobre 2012
Performance test - YaJUG Octobre 2012Claude Falguiere
 
JS-Everywhere - SSE Hands-on
JS-Everywhere - SSE Hands-onJS-Everywhere - SSE Hands-on
JS-Everywhere - SSE Hands-onBrice Argenson
 
Localizing iOS Apps
Localizing iOS AppsLocalizing iOS Apps
Localizing iOS Appsweissazool
 
LiveRebel + Pragmatic Continuous Delivery (Arcusys)
LiveRebel + Pragmatic Continuous Delivery (Arcusys)LiveRebel + Pragmatic Continuous Delivery (Arcusys)
LiveRebel + Pragmatic Continuous Delivery (Arcusys)Neeme Praks
 
Morning with MongoDB Paris 2012 - Accueil et Introductions
Morning with MongoDB Paris 2012 - Accueil et IntroductionsMorning with MongoDB Paris 2012 - Accueil et Introductions
Morning with MongoDB Paris 2012 - Accueil et IntroductionsMongoDB
 
Hadoop: A Hands-on Introduction
Hadoop: A Hands-on IntroductionHadoop: A Hands-on Introduction
Hadoop: A Hands-on IntroductionClaudio Martella
 
Multiplatform, Promises and HTML5
Multiplatform, Promises and HTML5Multiplatform, Promises and HTML5
Multiplatform, Promises and HTML5C4Media
 
Connect and Collaborate B: Version 3
Connect and Collaborate B: Version 3Connect and Collaborate B: Version 3
Connect and Collaborate B: Version 3Terri Sallee
 
Rspec group
Rspec groupRspec group
Rspec groupthefonso
 
Content focused web design
Content focused web designContent focused web design
Content focused web designEddie Monge
 

Similar to Enterprise javascriptsession2 (20)

Enterprise javascriptsession3
Enterprise javascriptsession3Enterprise javascriptsession3
Enterprise javascriptsession3
 
Enterprise javascriptsession1
Enterprise javascriptsession1Enterprise javascriptsession1
Enterprise javascriptsession1
 
Morning with MongoDB Paris 2012 - MongoDB Basic Concepts
Morning with MongoDB Paris 2012 - MongoDB Basic ConceptsMorning with MongoDB Paris 2012 - MongoDB Basic Concepts
Morning with MongoDB Paris 2012 - MongoDB Basic Concepts
 
JavaScript: The prototype Property
JavaScript: The prototype PropertyJavaScript: The prototype Property
JavaScript: The prototype Property
 
Why not to use Rails? (actually it's when not to use Rails)
Why not to use Rails? (actually it's when not to use Rails)Why not to use Rails? (actually it's when not to use Rails)
Why not to use Rails? (actually it's when not to use Rails)
 
Software Libraries And Numbers
Software Libraries And NumbersSoftware Libraries And Numbers
Software Libraries And Numbers
 
JS-Everywhere - LocalStorage Hands-on
JS-Everywhere - LocalStorage Hands-onJS-Everywhere - LocalStorage Hands-on
JS-Everywhere - LocalStorage Hands-on
 
Performance test - YaJUG Octobre 2012
Performance test - YaJUG Octobre 2012Performance test - YaJUG Octobre 2012
Performance test - YaJUG Octobre 2012
 
JS-Everywhere - SSE Hands-on
JS-Everywhere - SSE Hands-onJS-Everywhere - SSE Hands-on
JS-Everywhere - SSE Hands-on
 
Pocket Knife JS
Pocket Knife JSPocket Knife JS
Pocket Knife JS
 
Localizing iOS Apps
Localizing iOS AppsLocalizing iOS Apps
Localizing iOS Apps
 
LiveRebel + Pragmatic Continuous Delivery (Arcusys)
LiveRebel + Pragmatic Continuous Delivery (Arcusys)LiveRebel + Pragmatic Continuous Delivery (Arcusys)
LiveRebel + Pragmatic Continuous Delivery (Arcusys)
 
Morning with MongoDB Paris 2012 - Accueil et Introductions
Morning with MongoDB Paris 2012 - Accueil et IntroductionsMorning with MongoDB Paris 2012 - Accueil et Introductions
Morning with MongoDB Paris 2012 - Accueil et Introductions
 
Hadoop: A Hands-on Introduction
Hadoop: A Hands-on IntroductionHadoop: A Hands-on Introduction
Hadoop: A Hands-on Introduction
 
Multiplatform, Promises and HTML5
Multiplatform, Promises and HTML5Multiplatform, Promises and HTML5
Multiplatform, Promises and HTML5
 
Connect and Collaborate B: Version 3
Connect and Collaborate B: Version 3Connect and Collaborate B: Version 3
Connect and Collaborate B: Version 3
 
Rspec group
Rspec groupRspec group
Rspec group
 
Content focused web design
Content focused web designContent focused web design
Content focused web design
 
Mume2012
Mume2012Mume2012
Mume2012
 
living drupal
living drupalliving drupal
living drupal
 

More from Troy Miles

Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web ServersTroy Miles
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot CampTroy Miles
 
AWS Lambda Function with Kotlin
AWS Lambda Function with KotlinAWS Lambda Function with Kotlin
AWS Lambda Function with KotlinTroy Miles
 
React Native One Day
React Native One DayReact Native One Day
React Native One DayTroy Miles
 
React Native Evening
React Native EveningReact Native Evening
React Native EveningTroy Miles
 
Intro to React
Intro to ReactIntro to React
Intro to ReactTroy Miles
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN StackTroy Miles
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application TestingTroy Miles
 
What is Angular version 4?
What is Angular version 4?What is Angular version 4?
What is Angular version 4?Troy Miles
 
Angular Weekend
Angular WeekendAngular Weekend
Angular WeekendTroy Miles
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy Miles
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScriptTroy Miles
 
Functional Programming in Clojure
Functional Programming in ClojureFunctional Programming in Clojure
Functional Programming in ClojureTroy Miles
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-upTroy Miles
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You KnewTroy Miles
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Troy Miles
 
Build a Game in 60 minutes
Build a Game in 60 minutesBuild a Game in 60 minutes
Build a Game in 60 minutesTroy Miles
 
Quick & Dirty & MEAN
Quick & Dirty & MEANQuick & Dirty & MEAN
Quick & Dirty & MEANTroy Miles
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveXTroy Miles
 

More from Troy Miles (20)

Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web Servers
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
AWS Lambda Function with Kotlin
AWS Lambda Function with KotlinAWS Lambda Function with Kotlin
AWS Lambda Function with Kotlin
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application Testing
 
ReactJS.NET
ReactJS.NETReactJS.NET
ReactJS.NET
 
What is Angular version 4?
What is Angular version 4?What is Angular version 4?
What is Angular version 4?
 
Angular Weekend
Angular WeekendAngular Weekend
Angular Weekend
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
 
Functional Programming in Clojure
Functional Programming in ClojureFunctional Programming in Clojure
Functional Programming in Clojure
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You Knew
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 
Build a Game in 60 minutes
Build a Game in 60 minutesBuild a Game in 60 minutes
Build a Game in 60 minutes
 
Quick & Dirty & MEAN
Quick & Dirty & MEANQuick & Dirty & MEAN
Quick & Dirty & MEAN
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveX
 

Enterprise javascriptsession2

  • 1. Enterprise JavaScript Session 2 - Building Applications Wednesday, November 7, 12
  • 2. Hi, I’m Troy Wednesday, November 7, 12
  • 3. Hi, I’m Troy • Developing software Since 1979 • Initially Game Software in Assembly (6502 and x86) • Currently JavaScript, C#, Java, Objective-C • rockncoder@gmail.com Wednesday, November 7, 12
  • 4. jssaturday.com Nov. 10th, Long Beach Convention Center Discount code: RiaConsultingLLC Save $65!!! Wednesday, November 7, 12
  • 6. Today’s Agenda • Namespacing Wednesday, November 7, 12
  • 7. Today’s Agenda • Namespacing • Design Patterns Wednesday, November 7, 12
  • 8. Today’s Agenda • Namespacing • Design Patterns • Performance Wednesday, November 7, 12
  • 9. Today’s Agenda • Namespacing • Design Patterns • Performance • Debugging Wednesday, November 7, 12
  • 11. Namespacing Namespacing is a technique employed to avoid collisions with other objects or variables in the global namespace. They're also extremely useful for helping organize blocks of functionality in your application into easily manageable groups that can be uniquely identified. -- Addy Osmani Wednesday, November 7, 12
  • 13. Hands-on Exercise • In jsFiddle.net Wednesday, November 7, 12
  • 14. Hands-on Exercise • In jsFiddle.net • Create a global var named “myApp” Wednesday, November 7, 12
  • 15. Hands-on Exercise • In jsFiddle.net • Create a global var named “myApp” • If it has been defined already, make it equal to its previous instance Wednesday, November 7, 12
  • 16. Hands-on Exercise • In jsFiddle.net • Create a global var named “myApp” • If it has been defined already, make it equal to its previous instance • If it hasn’t been defined, make it equal to an empty object literal Wednesday, November 7, 12
  • 18. Answers 1. var myApp = myApp || {}; Wednesday, November 7, 12
  • 19. Answers 1. var myApp = myApp || {}; 2. if(!myApp) myApp = {}; Wednesday, November 7, 12
  • 20. Answers 1. var myApp = myApp || {}; 2. if(!myApp) myApp = {}; 3. myApp || (myApp = {}); Wednesday, November 7, 12
  • 21. Answers 1. var myApp = myApp || {}; 2. if(!myApp) myApp = {}; 3. myApp || (myApp = {}); 4. var myApp = myApp === undefined ? {} : myApp; Wednesday, November 7, 12
  • 23. Namespaces • Single global variables Wednesday, November 7, 12
  • 24. Namespaces • Single global variables • Object literal notation Wednesday, November 7, 12
  • 25. Namespaces • Single global variables • Object literal notation • Nested namespacing Wednesday, November 7, 12
  • 26. Namespaces • Single global variables • Object literal notation • Nested namespacing • Immediately-Invoked Function Expressions Wednesday, November 7, 12
  • 27. Namespaces • Single global variables • Object literal notation • Nested namespacing • Immediately-Invoked Function Expressions • Namespace Injection Wednesday, November 7, 12
  • 29. Single Global Variable • The entire application goes into a single global object, usually a function Wednesday, November 7, 12
  • 30. Single Global Variable • The entire application goes into a single global object, usually a function • An object literal is returned by the function Wednesday, November 7, 12
  • 31. Single Global Variable • The entire application goes into a single global object, usually a function • An object literal is returned by the function • Not well suited for team development since not easily decomposed Wednesday, November 7, 12
  • 32. Single Global Variable var myApplication = (function(){ function() { /*...*/ }, return{ /*...*/ }; })(); Wednesday, November 7, 12
  • 34. Object Literal Notation • Doesn’t pollute the global namespace Wednesday, November 7, 12
  • 35. Object Literal Notation • Doesn’t pollute the global namespace • Assist in organizing code into logical parts Wednesday, November 7, 12
  • 36. Object Literal Notation • Doesn’t pollute the global namespace • Assist in organizing code into logical parts • Easy to read Wednesday, November 7, 12
  • 38. Nested Namespacing • An extension of object literal notiation Wednesday, November 7, 12
  • 39. Nested Namespacing • An extension of object literal notiation • Even if a namespace already exists, unlikely that the children do Wednesday, November 7, 12
  • 40. Nested Namespacing • An extension of object literal notiation • Even if a namespace already exists, unlikely that the children do • Used extensively by JavaScript API vendors like Yahoo and Google Wednesday, November 7, 12
  • 41. Nested Namespacing • An extension of object literal notiation • Even if a namespace already exists, unlikely that the children do • Used extensively by JavaScript API vendors like Yahoo and Google • Negligible performance ding Wednesday, November 7, 12
  • 42. Immediately-Invoked Function Expressions Wednesday, November 7, 12
  • 43. Immediately-Invoked Function Expressions • Also known as “iffy” Wednesday, November 7, 12
  • 44. Immediately-Invoked Function Expressions • Also known as “iffy” • An unnamed function which is immediately invoked after it’s been defined Wednesday, November 7, 12
  • 45. Immediately-Invoked Function Expressions • Also known as “iffy” • An unnamed function which is immediately invoked after it’s been defined • Allows for information hiding Wednesday, November 7, 12
  • 46. Immediately-Invoked Function Expressions • Also known as “iffy” • An unnamed function which is immediately invoked after it’s been defined • Allows for information hiding • Improves minification results Wednesday, November 7, 12
  • 48. Namespace Injection • A variation of the IIFE Wednesday, November 7, 12
  • 49. Namespace Injection • A variation of the IIFE • Methods and properties get injected for a specific namespace Wednesday, November 7, 12
  • 50. Namespace Injection • A variation of the IIFE • Methods and properties get injected for a specific namespace • A bit cumbersome Wednesday, November 7, 12
  • 52. Namespaces • Most of my current code uses Nested Namespacing Wednesday, November 7, 12
  • 53. Namespaces • Most of my current code uses Nested Namespacing • My newest code uses IIFE Wednesday, November 7, 12
  • 56. Design Patterns • Singleton Wednesday, November 7, 12
  • 57. Design Patterns • Singleton • Chaining Wednesday, November 7, 12
  • 58. Design Patterns • Singleton • Chaining • Observer Wednesday, November 7, 12
  • 59. Design Patterns • Singleton • Chaining • Observer • Hands-on Exercise Wednesday, November 7, 12
  • 60. Singleton The singleton pattern is a design pattern that restricts the instantiation of a class to one object. Wednesday, November 7, 12
  • 61. When to Use a Singleton Wednesday, November 7, 12
  • 62. When to Use a Singleton • For namespacing or modularizing code, it should be used as often as possible Wednesday, November 7, 12
  • 63. When to Use a Singleton • For namespacing or modularizing code, it should be used as often as possible • In simple projects, a singleton can be used a a namespace Wednesday, November 7, 12
  • 64. When to Use a Singleton • For namespacing or modularizing code, it should be used as often as possible • In simple projects, a singleton can be used a a namespace • In larger projects, it can be used to group related code together Wednesday, November 7, 12
  • 65. Chaining Method chaining, also known as named parameter idiom, is a common technique for invoking multiple method calls in object- oriented programming languages. Wednesday, November 7, 12
  • 66. Chaining Not really a design pattern, more of a syntax hack, but its extensive use in JavaScript and JavaScript libraries requires explanation. Wednesday, November 7, 12
  • 68. Chaining • There are generally two types of methods: Wednesday, November 7, 12
  • 69. Chaining • There are generally two types of methods: • Accessors - return a value Wednesday, November 7, 12
  • 70. Chaining • There are generally two types of methods: • Accessors - return a value • Mutators - modify a property on the object and return “this” to enable chaining Wednesday, November 7, 12
  • 71. Observer The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems. Wednesday, November 7, 12
  • 73. Observer • Consist of three main components: Wednesday, November 7, 12
  • 74. Observer • Consist of three main components: • The Observer Wednesday, November 7, 12
  • 75. Observer • Consist of three main components: • The Observer • The Observer List Wednesday, November 7, 12
  • 76. Observer • Consist of three main components: • The Observer • The Observer List • The Subject Wednesday, November 7, 12
  • 78. Hands-on Exercise • http://jsfiddle.net/rockncoder/FkDRV/2/ Wednesday, November 7, 12
  • 79. Hands-on Exercise • http://jsfiddle.net/rockncoder/FkDRV/2/ • Hook an event handler to the “Click Me” button Wednesday, November 7, 12
  • 80. Hands-on Exercise • http://jsfiddle.net/rockncoder/FkDRV/2/ • Hook an event handler to the “Click Me” button • Have it some how cause the “log.me” event Wednesday, November 7, 12
  • 81. Hands-on Exercise • http://jsfiddle.net/rockncoder/FkDRV/2/ • Hook an event handler to the “Click Me” button • Have it some how cause the “log.me” event • Remember to pass a message, (msg) Wednesday, November 7, 12
  • 84. Performance • Big O-Notation Wednesday, November 7, 12
  • 85. Performance • Big O-Notation • Measuring Performance Wednesday, November 7, 12
  • 86. Performance • Big O-Notation • Measuring Performance • 5 Performance Tips Wednesday, November 7, 12
  • 87. Performance • Big O-Notation • Measuring Performance • 5 Performance Tips • Hands-on Exercise Wednesday, November 7, 12
  • 88. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.Yet we should not pass up our opportunities in that critical 3%. D. Knuth Wednesday, November 7, 12
  • 89. Big O Notation Wednesday, November 7, 12
  • 90. Big O Notation Wednesday, November 7, 12
  • 91. Big O Notation • O(1), Constant Wednesday, November 7, 12
  • 92. Big O Notation • O(1), Constant • O(n), Linear Wednesday, November 7, 12
  • 93. Big O Notation • O(1), Constant • O(n), Linear • O(n ^ 2), Quadratic Wednesday, November 7, 12
  • 94. Big O Notation • O(1), Constant • O(n), Linear • O(n ^ 2), Quadratic • O(2 ^ n), Exponential Wednesday, November 7, 12
  • 95. Big O Notation • O(1), Constant • O(n), Linear • O(n ^ 2), Quadratic • O(2 ^ n), Exponential • O(n!), Factorial Wednesday, November 7, 12
  • 97. Measuring Performance • JavaScript’s includes a Date object Wednesday, November 7, 12
  • 98. Measuring Performance • JavaScript’s includes a Date object • Date.getTime() measures time in milliseconds Wednesday, November 7, 12
  • 99. Measuring Performance • JavaScript’s includes a Date object • Date.getTime() measures time in milliseconds • Resolution is not fine enough so we do things multiple times Wednesday, November 7, 12
  • 100. Measuring Performance /* A simple performance measurer */ var elapsedTime, startTime = new Date().getTime(); /* Do some operations */ elapsedTime = new Date().getTime() - startTime; Wednesday, November 7, 12
  • 101. 5 Performance Tips Wednesday, November 7, 12
  • 102. Tip #5 Use as few files as possible Wednesday, November 7, 12
  • 103. Use as few files as possible Wednesday, November 7, 12
  • 104. Use as few files as possible • Browser can load multiple files at a time Wednesday, November 7, 12
  • 105. Use as few files as possible • Browser can load multiple files at a time • But only one JS file at a time Wednesday, November 7, 12
  • 106. Use as few files as possible • Browser can load multiple files at a time • But only one JS file at a time • Concatenate multiple JS file into one Wednesday, November 7, 12
  • 107. Use as few files as possible • Browser can load multiple files at a time • But only one JS file at a time • Concatenate multiple JS file into one • Compress JS files Wednesday, November 7, 12
  • 108. Use as few files as possible • Browser can load multiple files at a time • But only one JS file at a time • Concatenate multiple JS file into one • Compress JS files • Prefer JS at the bottom of the HTML file Wednesday, November 7, 12
  • 109. Tip #4 Prefer local variables Wednesday, November 7, 12
  • 111. Prefer local variables • Variables in scope found quicker Wednesday, November 7, 12
  • 112. Prefer local variables • Variables in scope found quicker • JS search local scope, then global Wednesday, November 7, 12
  • 113. Prefer local variables • Variables in scope found quicker • JS search local scope, then global • with creates a new scope level ahead of local Wednesday, November 7, 12
  • 114. Prefer local variables • Variables in scope found quicker • JS search local scope, then global • with creates a new scope level ahead of local • closures also create new scope level Wednesday, November 7, 12
  • 115. Global vs. Local Demo Wednesday, November 7, 12
  • 116. Prefer local variables • Property chains similar to var scoping • Objects closer in the chain found quicker Wednesday, November 7, 12
  • 118. Tip #3 Reduce the work done in loops Wednesday, November 7, 12
  • 119. Reduce the work done in loops Wednesday, November 7, 12
  • 120. Reduce the work done in loops • No real speed difference between: for, while and do_while Wednesday, November 7, 12
  • 121. Reduce the work done in loops • No real speed difference between: for, while and do_while • Avoid for_in Wednesday, November 7, 12
  • 122. Reduce the work done in loops • No real speed difference between: for, while and do_while • Avoid for_in • Watch library based for_each Wednesday, November 7, 12
  • 124. Tip #2 Learn jQuery Wednesday, November 7, 12
  • 126. Learn jQuery • Know what jQuery does Wednesday, November 7, 12
  • 127. Learn jQuery • Know what jQuery does • Be sure to evaluate its use Wednesday, November 7, 12
  • 128. Learn jQuery • Know what jQuery does • Be sure to evaluate its use • Cache the results of jQuery selectors Wednesday, November 7, 12
  • 130. Tip #1 Avoid the DOM Wednesday, November 7, 12
  • 131. Avoid the DOM Wednesday, November 7, 12
  • 132. Avoid the DOM • The DOM is REALLY Slow Wednesday, November 7, 12
  • 133. Avoid the DOM • The DOM is REALLY Slow • Avoid accessing it when possible Wednesday, November 7, 12
  • 134. Avoid the DOM • The DOM is REALLY Slow • Avoid accessing it when possible • Do work offline then update DOM Wednesday, November 7, 12
  • 135. DOM Access Demos Wednesday, November 7, 12
  • 137. Hands-on Exercise http://jsfiddle.net/rockncoder/HDWRb/4/ Wednesday, November 7, 12
  • 138. Hands-on Exercise http://jsfiddle.net/rockncoder/HDWRb/4/ Run the fiddle Wednesday, November 7, 12
  • 139. Hands-on Exercise http://jsfiddle.net/rockncoder/HDWRb/4/ Run the fiddle Note the execution time Wednesday, November 7, 12
  • 140. Hands-on Exercise http://jsfiddle.net/rockncoder/HDWRb/4/ Run the fiddle Note the execution time Improve the time Wednesday, November 7, 12
  • 141. Hands-on Exercise http://jsfiddle.net/rockncoder/HDWRb/4/ Run the fiddle Note the execution time Improve the time Have a question? Call me over Wednesday, November 7, 12
  • 143. Debugging • Chrome Developer Tools Wednesday, November 7, 12
  • 144. Debugging • Chrome Developer Tools • Safari Remote Debugging Wednesday, November 7, 12
  • 145. Debugging • Chrome Developer Tools • Safari Remote Debugging • Fiddler2 Wednesday, November 7, 12
  • 146. Debugging • Chrome Developer Tools • Safari Remote Debugging • Fiddler2 • Proxying an iPad Wednesday, November 7, 12
  • 147. Debugging • Chrome Developer Tools • Safari Remote Debugging • Fiddler2 • Proxying an iPad • Hands-on Exercise: Fiddler Wednesday, November 7, 12
  • 149. Chrome Developer Tools • ctrl-shift-J brings up the console Wednesday, November 7, 12
  • 150. Chrome Developer Tools • ctrl-shift-J brings up the console • View HTML Wednesday, November 7, 12
  • 151. Chrome Developer Tools • ctrl-shift-J brings up the console • View HTML • View/Modify Source Wednesday, November 7, 12
  • 152. Chrome Developer Tools • ctrl-shift-J brings up the console • View HTML • View/Modify Source • Set breakpoints Wednesday, November 7, 12
  • 154. Safari Remote Debugging • Settings > Safari > Advanced Wednesday, November 7, 12
  • 155. Safari Remote Debugging • Settings > Safari > Advanced • Web Inspector = ON Wednesday, November 7, 12
  • 156. Safari Remote Debugging • Settings > Safari > Advanced • Web Inspector = ON • Safari > Develop > iPad > website Wednesday, November 7, 12
  • 157. Safari Remote Debugging • Settings > Safari > Advanced • Web Inspector = ON • Safari > Develop > iPad > website • Similar to using Chrome Wednesday, November 7, 12
  • 159. Fiddler2 • http://www.fiddler2.com/fiddler2/ Wednesday, November 7, 12
  • 160. Fiddler2 • http://www.fiddler2.com/fiddler2/ • Web Debugging Proxy Wednesday, November 7, 12
  • 161. Fiddler2 • http://www.fiddler2.com/fiddler2/ • Web Debugging Proxy • View Web Traffic Wednesday, November 7, 12
  • 162. Fiddler2 • http://www.fiddler2.com/fiddler2/ • Web Debugging Proxy • View Web Traffic • Filter Web Traffic Wednesday, November 7, 12
  • 163. Fiddler2 • http://www.fiddler2.com/fiddler2/ • Web Debugging Proxy • View Web Traffic • Filter Web Traffic • Inspect Requests Wednesday, November 7, 12
  • 164. Fiddler2 • http://www.fiddler2.com/fiddler2/ • Web Debugging Proxy • View Web Traffic • Filter Web Traffic • Inspect Requests • Inspect Responses Wednesday, November 7, 12
  • 165. Proxying an iPad Wednesday, November 7, 12
  • 166. Proxying an iPad • Tools > Fiddler Options > Connections Wednesday, November 7, 12
  • 167. Proxying an iPad • Tools > Fiddler Options > Connections • Wi-Fi > (right arrow) > HTTP Proxy Wednesday, November 7, 12
  • 168. Proxying an iPad • Tools > Fiddler Options > Connections • Wi-Fi > (right arrow) > HTTP Proxy • Set Server & Port Wednesday, November 7, 12
  • 169. Proxying an iPad • Tools > Fiddler Options > Connections • Wi-Fi > (right arrow) > HTTP Proxy • Set Server & Port • Unfortunately Proxying an Android device is not as easy Wednesday, November 7, 12
  • 171. Hands-on Exercise • Twitter’s Search API is Open • The URL is http://search.twitter.com/ search.json?q={subject} • Using Fiddler make a request to Twitter about “sandy” • Use the JSON view to inspect the results Wednesday, November 7, 12
  • 172. The Code is Online https://github.com/Rockncoder/EnterpriseJavaScript Wednesday, November 7, 12
  • 174. Summary • Namespacing Wednesday, November 7, 12
  • 175. Summary • Namespacing • Design Patterns Wednesday, November 7, 12
  • 176. Summary • Namespacing • Design Patterns • Performance Wednesday, November 7, 12
  • 177. Summary • Namespacing • Design Patterns • Performance • Debugging Wednesday, November 7, 12