SlideShare a Scribd company logo
Engineering JavaScript
        Dr Jim Purbrick
     Async 10th March 2011
Who Am I?
Technical Director at Linden Lab
   Setup Linden Lab Brighton
       Software Engineer
            Musician
           Freelancer
          Entrepreneur
That’s No Moon...
35,000 CPU Cores

Weekly Releases

No Downtime

1.5 MLOC

100 Engineers

10 Years                        Image: jurvetson



C++, Python, Perl, PHP, C#...
21st Century JavaScript




   Image: Google
                   Image: W3C
Module
myOrg = (function(myOrg) {

    var myApp = myOrg.myApp = myOrg.myApp || {};

    function myPrivateFunction() {
        // Do my thing.
    }

    myApp.myPublicFunction = function() {
        return myPrivateFunction();
    }

    return myOrg;

}(myOrg || {}));
myOrg = (function(myOrg) {
                             Class
    var myApp = myOrg.myApp = myOrg.myApp || {},
        myClass = myOrg.myApp.myClass = myOrg.myApp.myClass || {};

    myClass.create = function() {

         var that = {};

         myPrivateMethod() {
         }

         that.myPublicMethod = function() {
             myPrivateMethod();
         };

         return that;
    };

    return myOrg;

}(myOrg || {}));
Inheritance
myOrg = (function(myOrg) {

    var myApp = myOrg.myApp = myOrg.myApp || {},
        mySub = myOrg.myApp.mySub = myOrg.myApp.mySub || {};

    mySub.create = function() {

         var that = myApp.myClass.create(),
             myClassMyPublicMethod = that.myPublicMethod;

         that.myPublicMethod = function() {
             // Do something.
             return myClassMyPublicMethod();
         };

         return that;
    };

    return myOrg;

}(myOrg || {}));
Dependency Injection
myOrg = (function(myOrg) {

    var myApp = myOrg.myApp = myOrg.myApp || {},
        mySub = myOrg.myApp.mySub = myOrg.myApp.mySub || {};

    mySub.create = function(params) {

         var that = params.constructor(),
             myClassMyPublicMethod = that.myPublicMethod,
             $ = params.jQuery;

         that.myPublicMethod = function() {
             return myClassMyPublicMethod();
         };

         return that;
    };

   return myOrg;

}(myOrg || {}));
Production
<script type="text/javascript">
$(window).load(function() {

    var params, mySubInstance;

    params = {
        constructor: myOrg.myClass.create,
        jQuery: jQuery
    };

    mySubInstance = myOrg.myApp.mySub.create(params);

    // Do something with mySubClassInstance.

};
</script>
Test
JsHamcrest.Integration.QUnit();
JsMockito.Integration.QUnit();

test('mySubClass calls super class constructor', function () {

      var params, mySubInstance;

      params = {
          constructor: mockFunction(),
          jQuery: mockFunction()
      };

      mySubInstance = myOrg.myApp.mySub.create(params);

      verify(params.constructor, once())();
});
More?
1. http://www.adequatelygood.com/2010/3/
   JavaScript-Module-Pattern-In-Depth
2. http://www.crockford.com/
3. http://oreilly.com/catalog/9780596517748
4. http://docs.jquery.com/Qunit
5. http://jsmockito.org/
Thank You!




http://jimpurbrick.com
http://18dex.com

More Related Content

PPT
Ruby on Rails Intro
zhang tao
 
KEY
Object-Oriented Javascript
kvangork
 
PDF
Reactive Programming Patterns with RxSwift
Florent Pillet
 
PDF
jsDay 2016 recap
Giorgio Cefaro
 
PDF
Composition in JavaScript
Josh Mock
 
PDF
みんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swift
Tomohiro Kumagai
 
PPTX
99 líneas que lo simplifican todo( sin animar)
nosina
 
PDF
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
Tsuyoshi Yamamoto
 
Ruby on Rails Intro
zhang tao
 
Object-Oriented Javascript
kvangork
 
Reactive Programming Patterns with RxSwift
Florent Pillet
 
jsDay 2016 recap
Giorgio Cefaro
 
Composition in JavaScript
Josh Mock
 
みんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swift
Tomohiro Kumagai
 
99 líneas que lo simplifican todo( sin animar)
nosina
 
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
Tsuyoshi Yamamoto
 

What's hot (20)

PDF
Introduction to cron queue
ADCI Solutions
 
PDF
How to practice functional programming in react
Netta Bondy
 
DOCX
Include
Shi Chakep
 
PDF
Javascript & Ajax Basics
Richard Paul
 
PDF
Functional Reactive Programming - RxSwift
Rodrigo Leite
 
PDF
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Tsuyoshi Yamamoto
 
PDF
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
Tsuyoshi Yamamoto
 
PDF
Reactive programming with RxSwift
Scott Gardner
 
PDF
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
Aaron Douglas
 
PDF
Reactive Programming with RxSwift
Scott Gardner
 
PDF
clara-rules
Ikuru Kanuma
 
PDF
Js interpreter interpreted
Martha Schumann
 
PDF
非同期javascriptの過去と未来
Taketoshi 青野健利
 
PDF
Spark Jobserver
Yegor Andreenko
 
PPTX
JavaScript Sprachraum
patricklee
 
PDF
G*なクラウド ~雲のかなたに~
Tsuyoshi Yamamoto
 
PDF
2016 gunma.web games-and-asm.js
Noritada Shimizu
 
PDF
20151224-games
Noritada Shimizu
 
PPTX
Groovy Api Tutorial
guligala
 
PDF
倒计时优化点滴
j5726
 
Introduction to cron queue
ADCI Solutions
 
How to practice functional programming in react
Netta Bondy
 
Include
Shi Chakep
 
Javascript & Ajax Basics
Richard Paul
 
Functional Reactive Programming - RxSwift
Rodrigo Leite
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Tsuyoshi Yamamoto
 
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
Tsuyoshi Yamamoto
 
Reactive programming with RxSwift
Scott Gardner
 
Swift & ReactiveX – Asynchronous Event-Based Funsies with RxSwift
Aaron Douglas
 
Reactive Programming with RxSwift
Scott Gardner
 
clara-rules
Ikuru Kanuma
 
Js interpreter interpreted
Martha Schumann
 
非同期javascriptの過去と未来
Taketoshi 青野健利
 
Spark Jobserver
Yegor Andreenko
 
JavaScript Sprachraum
patricklee
 
G*なクラウド ~雲のかなたに~
Tsuyoshi Yamamoto
 
2016 gunma.web games-and-asm.js
Noritada Shimizu
 
20151224-games
Noritada Shimizu
 
Groovy Api Tutorial
guligala
 
倒计时优化点滴
j5726
 
Ad

Similar to Engineering JavaScript (20)

KEY
Object-Oriented JavaScript
kvangork
 
PDF
Clean Javascript
Ryunosuke SATO
 
PPT
AngularJS Testing Strategies
njpst8
 
PDF
Java script object model
James Hsieh
 
PPTX
Design patterns in javascript
Miao Siyu
 
PDF
Say It With Javascript
Giovanni Scerra ☃
 
PPT
Javascript Design Patterns
Zohar Arad
 
PDF
Javascript Frameworks for Joomla
Luke Summerfield
 
PDF
TypeScript Introduction
Dmitry Sheiko
 
PDF
JavaScript and UI Architecture Best Practices
Siarhei Barysiuk
 
PPT
25-functions.ppt
JyothiAmpally
 
PDF
Javascript Design Patterns
Subramanyan Murali
 
PDF
Object Oriented JavaScript
Michael Girouard
 
PPTX
JavaScript (without DOM)
Piyush Katariya
 
PDF
The Beauty Of Java Script V5a
rajivmordani
 
PDF
Intro programacion funcional
NSCoder Mexico
 
KEY
連邦の白いヤツ 「Objective-C」
matuura_core
 
PDF
Design patterns in javascript
Abimbola Idowu
 
PDF
JavaScript Fundamentals with Angular and Lodash
Bret Little
 
PDF
What's new in jQuery 1.5
Martin Kleppe
 
Object-Oriented JavaScript
kvangork
 
Clean Javascript
Ryunosuke SATO
 
AngularJS Testing Strategies
njpst8
 
Java script object model
James Hsieh
 
Design patterns in javascript
Miao Siyu
 
Say It With Javascript
Giovanni Scerra ☃
 
Javascript Design Patterns
Zohar Arad
 
Javascript Frameworks for Joomla
Luke Summerfield
 
TypeScript Introduction
Dmitry Sheiko
 
JavaScript and UI Architecture Best Practices
Siarhei Barysiuk
 
25-functions.ppt
JyothiAmpally
 
Javascript Design Patterns
Subramanyan Murali
 
Object Oriented JavaScript
Michael Girouard
 
JavaScript (without DOM)
Piyush Katariya
 
The Beauty Of Java Script V5a
rajivmordani
 
Intro programacion funcional
NSCoder Mexico
 
連邦の白いヤツ 「Objective-C」
matuura_core
 
Design patterns in javascript
Abimbola Idowu
 
JavaScript Fundamentals with Angular and Lodash
Bret Little
 
What's new in jQuery 1.5
Martin Kleppe
 
Ad

Recently uploaded (20)

PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Software Development Methodologies in 2025
KodekX
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
The Future of Artificial Intelligence (AI)
Mukul
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 

Engineering JavaScript

Editor's Notes