SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Marionette.js
Make your Backbone applications dance!
Who am I
 Senior front end dev at Nulogy (we are hiring!)
 Email - matt@mattbriggs.net
 Tweeter - @googleninja
 Coding – http://github.com/mbriggs
 Slides – http://slideshare.net/matt-briggs
 Infrequently updated blog – http://mattbriggs.net
Evaluating Frameworks
Without Bias
 The power of backbone is its flexibility and simplicity
 It is incredibly easy to end up in a bad place
 If simplicity and flexibility are priorities, Backbone
should be considered
 All JS frameworks (like anything else in software)
have both strengths and weaknesses
 They are all great choices for very different reasons
 Choose the right tool for the job
Why We Went Backbone
 For Nulogy, we deal with huge amounts of
complicated business logic. Being able to evolve
architecture without framework constraints is of
very high value.
Marionette
 Takes the ideas of backbone a few steps further
 Still very simple
 Gives you primitives for building larger scale
applications
 Introduces some conventions to allow the
removal of boilerplate
 Introduces some ideas around building larger
applications
Marionette
Primitives
Marionette View Magic
 Takes care of rendering!
 Takes care of template management
 Provides UI object
 Provides .close()
 Extensibility points to allow customization of any
piece of this
Automatic Render
UI Object
Marionette.ItemView
 A view which is rendered based on model data
 “model” is your model
 “template” is a way to reference your template
 No render required!
 modelEvents – bind to view methods when
events fire on model
Model Events
Marionette.CollectionView
 View which renders based on a Collection
 Will automatically rerender on
add/remove/reset/etc
 Provide an itemView, which will get instantiated
automatically, and given a model
CollectionViews
Marionette.CompositeView
 Combination of an ItemView and a
CollctionView (has both a model and a
collection)
 Great for master/detail
 Useful for when a collection view is not enough
(like when rendering a table)
View Containers
Which also manage memory
Region
 Specialized view that holds other views
 Takes a view instance, calls render on it, and
adds it to the DOM
 The “bridge” between the DOM and the land of
backbone
Layout
 A specialized item view which has multiple
regions
 Great for a multi-view “widget”
Application
Structure
Separating coordination code from
computation code
Application
 An object to hold initialization and bootstrapping
logic
 This is the only place I allow knowledge of the full
page to live
Module
 Like an Application, but specialized for a specific
aspect of your code base
 An Application is made up of many Modules
Controller
 Mediate complex interaction between
components
 Useful when you start having a fair amount of
coordination logic building up somewhere –
break it out into a controller!
 Do not think about it in the MVC sense of the
word, more as a Use Case Controller.
Application
Level
Communication
ZOMG EVENTS!!
 In my experience, this is the most controversial
part of marionette
 Do not go down this road unless you are
reasonably sure it is the right one to go down.
Abuse of eventing will lead to unreadable code.
 Application level events are very close to global
function calls, keep that in mind.
 The different types of events are there to provide
additional semantic meaning to what kind of an
event It actually is.
EventAggregator
 Basically the same thing as EventEmitter in node
 You can trigger events
 You can bind to events
 Use these for when you just want to notify the
world of something happening, and multiple
parts of the application may want to respond (ie:
“user:logged-in”)
Commands
 A command is something which could be
triggered from multiple parts of the application,
but handled in a single place.
 Example: You can save by
 cmd-s
 Clicking a toolbar button
 Choosing File => Save from the menubar
Request/Response
 For when you want to provide some “Application
Level” data (for example, the current state of the
shopping cart)
 Great for “global state” without having to pass
around a mess of objects all over the place
 Easy to abuse – a method call against a
concrete object will always be more clear, and
once something is globally available, it is hard to
predict the impact of it changing
Let’s Look at
some code!

Weitere ähnliche Inhalte

Was ist angesagt?

Html5 and beyond the next generation of mobile web applications - Touch Tou...
Html5 and beyond   the next generation of mobile web applications - Touch Tou...Html5 and beyond   the next generation of mobile web applications - Touch Tou...
Html5 and beyond the next generation of mobile web applications - Touch Tou...
RIA RUI Society
 
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devicesSlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
reebalazs
 

Was ist angesagt? (20)

SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web AppsSenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps
 
Deep dive into AngularJs for Beginners
Deep dive into AngularJs for BeginnersDeep dive into AngularJs for Beginners
Deep dive into AngularJs for Beginners
 
Single Page Applications
Single Page ApplicationsSingle Page Applications
Single Page Applications
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAE
 
Html5 and beyond the next generation of mobile web applications - Touch Tou...
Html5 and beyond   the next generation of mobile web applications - Touch Tou...Html5 and beyond   the next generation of mobile web applications - Touch Tou...
Html5 and beyond the next generation of mobile web applications - Touch Tou...
 
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devicesSlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
 
Wulin kungfu final
Wulin kungfu finalWulin kungfu final
Wulin kungfu final
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
Organized web app development using backbone.js
Organized web app development using backbone.jsOrganized web app development using backbone.js
Organized web app development using backbone.js
 
Introduction to Angular JS
Introduction to Angular JSIntroduction to Angular JS
Introduction to Angular JS
 
Agile documentation with Confluence and Sparx Enterprise Architect
Agile documentation with Confluence and Sparx Enterprise ArchitectAgile documentation with Confluence and Sparx Enterprise Architect
Agile documentation with Confluence and Sparx Enterprise Architect
 
Kickstart sencha extjs
Kickstart sencha extjsKickstart sencha extjs
Kickstart sencha extjs
 
Skroutz Android MVP and Adapter Delegates presentation
Skroutz Android MVP and Adapter Delegates  presentationSkroutz Android MVP and Adapter Delegates  presentation
Skroutz Android MVP and Adapter Delegates presentation
 
Flexible UI Components for a Multi-Framework World
Flexible UI Components for a Multi-Framework WorldFlexible UI Components for a Multi-Framework World
Flexible UI Components for a Multi-Framework World
 
Angular js for beginners
Angular js for beginnersAngular js for beginners
Angular js for beginners
 
You Know WebOS
You Know WebOSYou Know WebOS
You Know WebOS
 
Vue.js Getting Started
Vue.js Getting StartedVue.js Getting Started
Vue.js Getting Started
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular js
 
Transforming Front-End Disaster Code™ Into A Maintainable Masterpiece
Transforming Front-End Disaster Code™ Into A Maintainable MasterpieceTransforming Front-End Disaster Code™ Into A Maintainable Masterpiece
Transforming Front-End Disaster Code™ Into A Maintainable Masterpiece
 

Ähnlich wie Marionette - TorontoJS

Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSSeminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Mizanur Sarker
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
danhaley45372
 
Александр Белецкий "Архитектура Javascript приложений"
 Александр Белецкий "Архитектура Javascript приложений" Александр Белецкий "Архитектура Javascript приложений"
Александр Белецкий "Архитектура Javascript приложений"
Agile Base Camp
 

Ähnlich wie Marionette - TorontoJS (20)

Building Scalable JavaScript Apps
Building Scalable JavaScript AppsBuilding Scalable JavaScript Apps
Building Scalable JavaScript Apps
 
No more Three Tier - A path to a better code for Cloud and Azure
No more Three Tier - A path to a better code for Cloud and AzureNo more Three Tier - A path to a better code for Cloud and Azure
No more Three Tier - A path to a better code for Cloud and Azure
 
Designing Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAsDesigning Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAs
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
 
Better User Experience with .NET
Better User Experience with .NETBetter User Experience with .NET
Better User Experience with .NET
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSSeminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
 
Building a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekBuilding a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one week
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 
Development and QA dilemmas in DevOps
Development and QA dilemmas in DevOpsDevelopment and QA dilemmas in DevOps
Development and QA dilemmas in DevOps
 
PureMVC
PureMVCPureMVC
PureMVC
 
Александр Белецкий "Архитектура Javascript приложений"
 Александр Белецкий "Архитектура Javascript приложений" Александр Белецкий "Архитектура Javascript приложений"
Александр Белецкий "Архитектура Javascript приложений"
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular App
 
Best practices for creating modular Web applications
Best practices for creating modular Web applicationsBest practices for creating modular Web applications
Best practices for creating modular Web applications
 
Design pattern
Design patternDesign pattern
Design pattern
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
 
Metamorphosis from Forms to Java: A technical lead's perspective, part II
Metamorphosis from Forms to Java:  A technical lead's perspective, part IIMetamorphosis from Forms to Java:  A technical lead's perspective, part II
Metamorphosis from Forms to Java: A technical lead's perspective, part II
 
Developing large scale JavaScript applications
Developing large scale JavaScript applicationsDeveloping large scale JavaScript applications
Developing large scale JavaScript applications
 
Micro-Frontends JSVidCon
Micro-Frontends JSVidConMicro-Frontends JSVidCon
Micro-Frontends JSVidCon
 
Flutter vs ReactNative
Flutter vs ReactNativeFlutter vs ReactNative
Flutter vs ReactNative
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Marionette - TorontoJS

  • 1. Marionette.js Make your Backbone applications dance!
  • 2. Who am I  Senior front end dev at Nulogy (we are hiring!)  Email - matt@mattbriggs.net  Tweeter - @googleninja  Coding – http://github.com/mbriggs  Slides – http://slideshare.net/matt-briggs  Infrequently updated blog – http://mattbriggs.net
  • 3. Evaluating Frameworks Without Bias  The power of backbone is its flexibility and simplicity  It is incredibly easy to end up in a bad place  If simplicity and flexibility are priorities, Backbone should be considered  All JS frameworks (like anything else in software) have both strengths and weaknesses  They are all great choices for very different reasons  Choose the right tool for the job
  • 4. Why We Went Backbone  For Nulogy, we deal with huge amounts of complicated business logic. Being able to evolve architecture without framework constraints is of very high value.
  • 5. Marionette  Takes the ideas of backbone a few steps further  Still very simple  Gives you primitives for building larger scale applications  Introduces some conventions to allow the removal of boilerplate  Introduces some ideas around building larger applications
  • 7. Marionette View Magic  Takes care of rendering!  Takes care of template management  Provides UI object  Provides .close()  Extensibility points to allow customization of any piece of this
  • 10. Marionette.ItemView  A view which is rendered based on model data  “model” is your model  “template” is a way to reference your template  No render required!  modelEvents – bind to view methods when events fire on model
  • 12. Marionette.CollectionView  View which renders based on a Collection  Will automatically rerender on add/remove/reset/etc  Provide an itemView, which will get instantiated automatically, and given a model
  • 14. Marionette.CompositeView  Combination of an ItemView and a CollctionView (has both a model and a collection)  Great for master/detail  Useful for when a collection view is not enough (like when rendering a table)
  • 15. View Containers Which also manage memory
  • 16. Region  Specialized view that holds other views  Takes a view instance, calls render on it, and adds it to the DOM  The “bridge” between the DOM and the land of backbone
  • 17. Layout  A specialized item view which has multiple regions  Great for a multi-view “widget”
  • 19. Application  An object to hold initialization and bootstrapping logic  This is the only place I allow knowledge of the full page to live
  • 20. Module  Like an Application, but specialized for a specific aspect of your code base  An Application is made up of many Modules
  • 21. Controller  Mediate complex interaction between components  Useful when you start having a fair amount of coordination logic building up somewhere – break it out into a controller!  Do not think about it in the MVC sense of the word, more as a Use Case Controller.
  • 23. ZOMG EVENTS!!  In my experience, this is the most controversial part of marionette  Do not go down this road unless you are reasonably sure it is the right one to go down. Abuse of eventing will lead to unreadable code.  Application level events are very close to global function calls, keep that in mind.  The different types of events are there to provide additional semantic meaning to what kind of an event It actually is.
  • 24. EventAggregator  Basically the same thing as EventEmitter in node  You can trigger events  You can bind to events  Use these for when you just want to notify the world of something happening, and multiple parts of the application may want to respond (ie: “user:logged-in”)
  • 25. Commands  A command is something which could be triggered from multiple parts of the application, but handled in a single place.  Example: You can save by  cmd-s  Clicking a toolbar button  Choosing File => Save from the menubar
  • 26. Request/Response  For when you want to provide some “Application Level” data (for example, the current state of the shopping cart)  Great for “global state” without having to pass around a mess of objects all over the place  Easy to abuse – a method call against a concrete object will always be more clear, and once something is globally available, it is hard to predict the impact of it changing

Hinweis der Redaktion

  1. Backbone was the first framework designed to help structure large scale javascriptOther frameworks have come since which are MUCH more sophisticated and specializedBy giving no guidance, it is easy to do backbone “wrong”. Because of that, many see it as obsolete.Every project out there has strengths and weaknesses, and should be evaluated objectively and with as little bias as possible.The strength of backbone is in its simplicity and flexibility. Despite what is said, nothing else covers those two points quite as well
  2. you can dig into any part of marionette and understand it in a few minutes (this is not to be underestimated!)