SlideShare uma empresa Scribd logo
1 de 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!

Mais conteúdo relacionado

Último

Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
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
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
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
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
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
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 

Último (20)

Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
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
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
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
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
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
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 

Destaque

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
 

Destaque (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!

Notas do Editor