SlideShare a Scribd company logo
1 of 40
How To Manage Large
Applications with jQuery or
whatever
Alex Sexton
@slexaxton
Bay Area jQuery Conference 2010 BAjQCON
WHY?


  Because I’m tired of stuff like this
WHY!?
WHY!?!!11one


 And you’re probably tired of maintaining it.
Wouldn’t this be nice?
Start thinking about our sites as Apps instead of a pile
of scripts.
IN A WORLD:
(Read this in the movie-trailer-guy smoky-voice)

  Where changing the dom doesn’t break your app
  Where you can re-use portions of your code (OMG)
  Where your files are separated based on tasks, but
  aren’t loaded by the hundreds at the top of your page
  Where you look at your code, and you understand
  what it does.
IN A WORLD:
(Read this in the movie-trailer-guy smoky-voice)

  Where changing the dom doesn’t break your app
  Where you can re-use portions of your code (OMG)
  Where your files are separated based on tasks, but
  aren’t loaded by the hundreds at the top of your page
  Where you look at your code, and you understand
  what it does.
IN A WORLD:
(Read this in the movie-trailer-guy smoky-voice)

  Where changing the dom doesn’t break your app
  Where you can re-use portions of your code (OMG)
  Where your files are separated based on tasks,
  but aren’t loaded by the hundreds at the top of
  your page
  Where you look at your code, and you understand
  what it does.
IN A WORLD:
(Read this in the movie-trailer-guy smoky-voice)

  Where changing the dom doesn’t break your app
  Where you can re-use portions of your code (OMG)
  Where your files are separated based on tasks, but
  aren’t loaded by the hundreds at the top of your page
  Where you look at your code, and you understand
  what it does.
Let’s Arbitrarily Pick Four
Things, kk?

 Inheritance Model
 Configurable Mixin Options
 Dom to Object Bridge
 Dependency Management
Inheritance Model
Pick what you like, I really really don’t care which



  Native / Pseudo-Classical (<-- Crock’s word not mine)
  Classical
  Prototypal
                                             Inheritance
Native / PseudoClassical
Native / PseudoClassical
 Weird, I know

 Blame Java (Brendan Eich is blameless (ok maybe not but still...))

 JavaScript (ECMA) is a Functional language with
 Imperative/Classical syntax (Specifically like if Java took advantage of Scheme)

 Important to grok, and easy once you get the hang of
 it, even if you never use it / hate it.
Classical Inheritance
Classical Inheritance
 If you’ve ever taken a programming course, you already
 know this (AKA a good starting point)

 Has some overhead since it isn’t native

 Not really the JavaScriptiest way to do it, but who
 cares?

 There’s a bunch-o-options: Simple Inheritance,
 Mootools Classes, LowPro, Base2, and MOAR!
Prototypal Inheritance
Prototypal Inheritance
Prototypal Inheritance


 Papa Crockford likes it and I kinda like him
 Fits into the language the best
 jQuery.extend means easy Multiple Inheritance!
 Not always complex enough, forealz
Quote from Crocky

“It doesn't matter what an
object's lineage is, what
matters is the quality of its
contents”
KK, I get Inheritance, sup next?
KK, I get Inheritance, sup next?
     Yeah right, but ok, we’ll move on.
Configurable Mixin Options
or a fancy name for Jamming
Two Objects together
Always do this.
Trust me.
It works better than Find in Files -> “#BADA55”
Let’s get a little more
advanced.


 The DOM to Object Bridge (yes, this is a list)
DOM <-> Object

If you start with a DOM Element, easily get back to its
related Object in your App (good for user interaction)
Describe your site in Objects, but still have an easy link
to it’s displayed DOM element (good for automatic
things)
Step 1: Create Your Object
Step 2: Create A Bridge
Step 3: Marvel at how much
more modular you just got.




More importantly, everything is configurable from a
                   single place.
AAAND if you somehow end up with the DOM
element, and you need to execute a plugin function:
OK, so now I’m modular, but
I have 18 files loading, what
would Steve Souders think?!

 Dependency Management FTMFW
Dependency Management

Javascript doesn’t do this by default like many
languages (include, require, etc)
Can be done serverside or clientside these days
Smart people already did all the hard work (Pretty much just James
Burke, but that must mean he’s really good at it though...)
Dependency Management
RequireJS

It takes some configuration. Get over it.
It’s actually faster than just including script tags, since
it’s asynchronous by default. yay steve!
Takes a few instructions and only loads what’s
necessary when it’s necessary.
RequireJS




 Wrap a module with its dependencies and
RequireJS will ensure those dependencies are
                   loaded.
RequireJS

This is great during development, but loading
everything individually during production might cause
some slowdown.
You can run a server-side build based on your
RequireJS dependency tree and get exactly what you
need combined and minified.
LabJS
LabJS is not for dependency management in the
strictest terms, but it is a lighter weight alternative to
RequireJS that helps you load everything in the highest
performing manner possible.




 Here, you tell LabJS what modules need to finish
 executing before being executing the next ones.
In the end

 You have clearly defined modules.
 You have easy bridges between your dom and your
 objects, but they are loosely coupled.
 You load your app as a single call, and the
 dependencies are figured out.
 Your page’s performance increases as well as your
 sanity level
Fin.
    Alex Sexton                                         BFFS4EVAR
    AlexSexton[at]gmail
    @slexaxton
    http://alexsexton.com/
    http://yayquery.com/
    http://alexsexton.com/inheritance/demo

Special Thanks to: Mike & Pierson Taylor, Paul Irish, Rebecca Murphey, Adam J Sontag,
John Resig, James Burke, Kyle Simpson, Crock, Eich and everyone who watches
yayQuery!

More Related Content

Recently uploaded

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 

Recently uploaded (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

How To Manage Large jQuery Apps

  • 1. How To Manage Large Applications with jQuery or whatever Alex Sexton @slexaxton Bay Area jQuery Conference 2010 BAjQCON
  • 2. WHY? Because I’m tired of stuff like this
  • 4. WHY!?!!11one And you’re probably tired of maintaining it.
  • 5. Wouldn’t this be nice? Start thinking about our sites as Apps instead of a pile of scripts.
  • 6. IN A WORLD: (Read this in the movie-trailer-guy smoky-voice) Where changing the dom doesn’t break your app Where you can re-use portions of your code (OMG) Where your files are separated based on tasks, but aren’t loaded by the hundreds at the top of your page Where you look at your code, and you understand what it does.
  • 7. IN A WORLD: (Read this in the movie-trailer-guy smoky-voice) Where changing the dom doesn’t break your app Where you can re-use portions of your code (OMG) Where your files are separated based on tasks, but aren’t loaded by the hundreds at the top of your page Where you look at your code, and you understand what it does.
  • 8. IN A WORLD: (Read this in the movie-trailer-guy smoky-voice) Where changing the dom doesn’t break your app Where you can re-use portions of your code (OMG) Where your files are separated based on tasks, but aren’t loaded by the hundreds at the top of your page Where you look at your code, and you understand what it does.
  • 9. IN A WORLD: (Read this in the movie-trailer-guy smoky-voice) Where changing the dom doesn’t break your app Where you can re-use portions of your code (OMG) Where your files are separated based on tasks, but aren’t loaded by the hundreds at the top of your page Where you look at your code, and you understand what it does.
  • 10. Let’s Arbitrarily Pick Four Things, kk? Inheritance Model Configurable Mixin Options Dom to Object Bridge Dependency Management
  • 11. Inheritance Model Pick what you like, I really really don’t care which Native / Pseudo-Classical (<-- Crock’s word not mine) Classical Prototypal Inheritance
  • 13. Native / PseudoClassical Weird, I know Blame Java (Brendan Eich is blameless (ok maybe not but still...)) JavaScript (ECMA) is a Functional language with Imperative/Classical syntax (Specifically like if Java took advantage of Scheme) Important to grok, and easy once you get the hang of it, even if you never use it / hate it.
  • 15. Classical Inheritance If you’ve ever taken a programming course, you already know this (AKA a good starting point) Has some overhead since it isn’t native Not really the JavaScriptiest way to do it, but who cares? There’s a bunch-o-options: Simple Inheritance, Mootools Classes, LowPro, Base2, and MOAR!
  • 18. Prototypal Inheritance Papa Crockford likes it and I kinda like him Fits into the language the best jQuery.extend means easy Multiple Inheritance! Not always complex enough, forealz
  • 19. Quote from Crocky “It doesn't matter what an object's lineage is, what matters is the quality of its contents”
  • 20. KK, I get Inheritance, sup next?
  • 21. KK, I get Inheritance, sup next? Yeah right, but ok, we’ll move on.
  • 22. Configurable Mixin Options or a fancy name for Jamming Two Objects together
  • 24. Trust me. It works better than Find in Files -> “#BADA55”
  • 25.
  • 26. Let’s get a little more advanced. The DOM to Object Bridge (yes, this is a list)
  • 27. DOM <-> Object If you start with a DOM Element, easily get back to its related Object in your App (good for user interaction) Describe your site in Objects, but still have an easy link to it’s displayed DOM element (good for automatic things)
  • 28. Step 1: Create Your Object
  • 29. Step 2: Create A Bridge
  • 30. Step 3: Marvel at how much more modular you just got. More importantly, everything is configurable from a single place.
  • 31. AAAND if you somehow end up with the DOM element, and you need to execute a plugin function:
  • 32. OK, so now I’m modular, but I have 18 files loading, what would Steve Souders think?! Dependency Management FTMFW
  • 33. Dependency Management Javascript doesn’t do this by default like many languages (include, require, etc) Can be done serverside or clientside these days Smart people already did all the hard work (Pretty much just James Burke, but that must mean he’s really good at it though...)
  • 35. RequireJS It takes some configuration. Get over it. It’s actually faster than just including script tags, since it’s asynchronous by default. yay steve! Takes a few instructions and only loads what’s necessary when it’s necessary.
  • 36. RequireJS Wrap a module with its dependencies and RequireJS will ensure those dependencies are loaded.
  • 37. RequireJS This is great during development, but loading everything individually during production might cause some slowdown. You can run a server-side build based on your RequireJS dependency tree and get exactly what you need combined and minified.
  • 38. LabJS LabJS is not for dependency management in the strictest terms, but it is a lighter weight alternative to RequireJS that helps you load everything in the highest performing manner possible. Here, you tell LabJS what modules need to finish executing before being executing the next ones.
  • 39. In the end You have clearly defined modules. You have easy bridges between your dom and your objects, but they are loosely coupled. You load your app as a single call, and the dependencies are figured out. Your page’s performance increases as well as your sanity level
  • 40. Fin. Alex Sexton BFFS4EVAR AlexSexton[at]gmail @slexaxton http://alexsexton.com/ http://yayquery.com/ http://alexsexton.com/inheritance/demo Special Thanks to: Mike & Pierson Taylor, Paul Irish, Rebecca Murphey, Adam J Sontag, John Resig, James Burke, Kyle Simpson, Crock, Eich and everyone who watches yayQuery!

Editor's Notes