SlideShare a Scribd company logo
1 of 18
Composite Architecture with
       Marionette
  Building a scalable javascript application
Problems.

• Managing UI interactions gets complex very
 quickly

• UI interactions have a way of coupling
 everything together

• Having a page not reload means significant
 parts of it can change many times, and
 everything else still needs to work.
Solution (sound architecture).

• "The key is to acknowledge from the start that you have no idea
  how this will grow. When you accept that you don't know
  everything, you begin to design the system defensively. You
  identify the key areas that may change, which often is very easy
  when you put a little bit of time into it. For instance, you should
  expect that any part of the app that communicates with another
  system will likely change, so you need to abstract that away."
  -Nicholas Zakas, author 'High-performance JavaScript websites'

• "The more tied components are to each other, the less reusable
  they will be, and the more difficult it becomes to make changes
  to one without accidentally affecting another"
  - Rebecca Murphey, author of jQuery Fundamentals.
"The secret to building large apps is
never build large apps. Break your
applications into small pieces. Then,
assemble those testable, bite-sized
pieces into your big application"
- Justin Meyer, author JavaScriptMVC
Marionette.Application

• Application objects are all about managing
 environment by providing ways to start, stop,
 and provide functionality

• Keeping applications isolated is key
• An application can have many sub applications
• There is no distinction between an
 “application” and an object
Mediator Pattern
• As soon as one class calls methods on another
 class, you introduce coupling. This is (usually)
 fine at the class level.

• Modules are a higher level then classes, this
 type of coupling has higher cost for them.

• Instead of direct interaction, a mediator
 provides a single thing everyone knows about,
 and its responsibility is to manage the messages
 between them
Mediator Pattern
The three communication
 mechanisms in Marionette

• Commands Provide functionality to the
 application

• Request/Response Ask for some type of
 value

• Event Let the application know that
 something happened
Commands
• Useful when you want to provide functionality
 that will be handled at a single point, but could
 be triggered anywhere.
Request / Response

• Useful when you want to request some kind of
 information from another part of the
 application
Events
• Useful when you want to broadcast that
 something happened, and it could be
 something that many other modules are
 interested in.
Common Application
    Structure
The Application
• Primary responsibility is to start and stop sub
 applications.

• Mediates cross sub-application communication
 (if necessary)

• Often responsible for managing views that
 trigger major shifts in what sub applications in
 play.

• Often provides a super high level layout
 manager
Sub Application

• Often correlates to a “screen”
• Responsible for doing what is required for
 screen changes

• Mediates module communication
• Responsible for managing layout, and pushes
 regions down to modules for them to use for
 their views
Module


• Provide a high level piece of functionality (like
 “The Sidebar”)

• Usually visual, but doesn’t have to be
• “End of the road”, this is what manages the
 objects that actually provide functionality
Good Ideas

• Don’t bind modules commands/responses
 directly to their implementations, have a
 controller in between them

• The previous breakdown is not set in stone,
 the hierarchy should change based on the
 requirements of the system

• Since modules are composable, a good
 approach is to start with one, and split it apart
 as more functionality are requirements develop
Things to keep in mind
• Eventing provides a high level of decoupling,
 with a cost of making code harder to follow.

• Decoupling at a low level will usually result in
 as bad a mess as too much coupling at a high
 level

• OO is all about messages passing between
 networks of objects. All we are doing is
 adapting what we do in the small to make it
 appropriate for large scale design.
Further Reading

• Enterprise Integration Patterns - the “bible” of
 large scale design http://www.eaipatterns.com/

• Patterns for Large Scale Javascript Application
 Archetecture by Addy Osmani - http://
 addyosmani.com/largescalejavascript/

• BBCloneMail - Marionette sample application
 https://github.com/derickbailey/bbclonemail

More Related Content

What's hot

Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in ComponentsFITC
 
Gitter marionette deck
Gitter marionette deckGitter marionette deck
Gitter marionette deckMike Bartlett
 
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 AppsSencha
 
Introduction to Backbone.js
Introduction to Backbone.jsIntroduction to Backbone.js
Introduction to Backbone.jsPragnesh Vaghela
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneJavascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneDeepu S Nath
 
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 WorldKevin Ball
 
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 devicesreebalazs
 
Mvvm knockout vs angular
Mvvm knockout vs angularMvvm knockout vs angular
Mvvm knockout vs angularBasarat Syed
 
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 ArchitectPer Spilling
 
Wulin kungfu final
Wulin kungfu finalWulin kungfu final
Wulin kungfu finalJimmy Huang
 
Javascript spaghetti stirtrek_5_17
Javascript  spaghetti stirtrek_5_17Javascript  spaghetti stirtrek_5_17
Javascript spaghetti stirtrek_5_17Jared Faris
 
Deep dive into AngularJs for Beginners
Deep dive into AngularJs for BeginnersDeep dive into AngularJs for Beginners
Deep dive into AngularJs for BeginnersVassilis Pitsounis
 
Tools For jQuery Application Architecture (Extended Slides)
Tools For jQuery Application Architecture (Extended Slides)Tools For jQuery Application Architecture (Extended Slides)
Tools For jQuery Application Architecture (Extended Slides)Addy Osmani
 
How to Use WebVR to Enhance the Web Experience
How to Use WebVR to Enhance the Web ExperienceHow to Use WebVR to Enhance the Web Experience
How to Use WebVR to Enhance the Web ExperienceFITC
 
Harness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkHarness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkBorisMoore
 
Smooth Animations for Web & Hybrid
Smooth Animations for Web & HybridSmooth Animations for Web & Hybrid
Smooth Animations for Web & HybridFITC
 
Choosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkitChoosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkitHristo Chakarov
 

What's hot (20)

Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in Components
 
Gitter marionette deck
Gitter marionette deckGitter marionette deck
Gitter marionette deck
 
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
 
Introduction to Backbone.js
Introduction to Backbone.jsIntroduction to Backbone.js
Introduction to Backbone.js
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneJavascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
 
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
 
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
 
Mvvm knockout vs angular
Mvvm knockout vs angularMvvm knockout vs angular
Mvvm knockout vs angular
 
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
 
Wulin kungfu final
Wulin kungfu finalWulin kungfu final
Wulin kungfu final
 
Javascript spaghetti stirtrek_5_17
Javascript  spaghetti stirtrek_5_17Javascript  spaghetti stirtrek_5_17
Javascript spaghetti stirtrek_5_17
 
Deep dive into AngularJs for Beginners
Deep dive into AngularJs for BeginnersDeep dive into AngularJs for Beginners
Deep dive into AngularJs for Beginners
 
Tools For jQuery Application Architecture (Extended Slides)
Tools For jQuery Application Architecture (Extended Slides)Tools For jQuery Application Architecture (Extended Slides)
Tools For jQuery Application Architecture (Extended Slides)
 
Single Page Applications
Single Page ApplicationsSingle Page Applications
Single Page Applications
 
How to Use WebVR to Enhance the Web Experience
How to Use WebVR to Enhance the Web ExperienceHow to Use WebVR to Enhance the Web Experience
How to Use WebVR to Enhance the Web Experience
 
Harness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkHarness jQuery Templates and Data Link
Harness jQuery Templates and Data Link
 
Sfk13
Sfk13Sfk13
Sfk13
 
Smooth Animations for Web & Hybrid
Smooth Animations for Web & HybridSmooth Animations for Web & Hybrid
Smooth Animations for Web & Hybrid
 
Choosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkitChoosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkit
 

Similar to Building Scalable JS Apps with Marionette

Understanding Microservices
Understanding Microservices Understanding Microservices
Understanding Microservices M A Hossain Tonu
 
ADUF - Adaptable Design Up Front
ADUF -  Adaptable Design Up FrontADUF -  Adaptable Design Up Front
ADUF - Adaptable Design Up FrontHayim Makabee
 
Александр Белецкий "Архитектура Javascript приложений"
 Александр Белецкий "Архитектура Javascript приложений" Александр Белецкий "Архитектура Javascript приложений"
Александр Белецкий "Архитектура Javascript приложений"Agile Base Camp
 
Migrating from Java EE to cloud-native Reactive systems
Migrating from Java EE to cloud-native Reactive systemsMigrating from Java EE to cloud-native Reactive systems
Migrating from Java EE to cloud-native Reactive systemsMarkus Eisele
 
Migrating From Java EE To Cloud-Native Reactive Systems
Migrating From Java EE To Cloud-Native Reactive SystemsMigrating From Java EE To Cloud-Native Reactive Systems
Migrating From Java EE To Cloud-Native Reactive SystemsLightbend
 
Over view of software artitecture
Over view of software artitectureOver view of software artitecture
Over view of software artitectureABDEL RAHMAN KARIM
 
MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.PLovababu
 
Large-Scale JavaScript Development
Large-Scale JavaScript DevelopmentLarge-Scale JavaScript Development
Large-Scale JavaScript DevelopmentAddy Osmani
 
MICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptxMICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptxMohammedShahid562503
 
System design process.pptx
System design process.pptxSystem design process.pptx
System design process.pptxNajibMuhammad16
 
Software Architecture for Agile Development
Software Architecture for Agile DevelopmentSoftware Architecture for Agile Development
Software Architecture for Agile DevelopmentHayim Makabee
 
An overview of Scalable Web Application Front-end
An overview of Scalable Web Application Front-endAn overview of Scalable Web Application Front-end
An overview of Scalable Web Application Front-endSaeid Zebardast
 
Micronaut Framework Guide Framework Basics and Fundamentals.pdf
Micronaut Framework Guide Framework Basics and Fundamentals.pdfMicronaut Framework Guide Framework Basics and Fundamentals.pdf
Micronaut Framework Guide Framework Basics and Fundamentals.pdfInexture Solutions
 
Fad-Free Architecture
Fad-Free ArchitectureFad-Free Architecture
Fad-Free ArchitectureJustin Munger
 
Mobile app-and-microservices-with-ibm-cloud
Mobile app-and-microservices-with-ibm-cloudMobile app-and-microservices-with-ibm-cloud
Mobile app-and-microservices-with-ibm-cloudSrinivasan Nanduri
 
Lecture_1_Introduction (Web Engineering).ppt
Lecture_1_Introduction (Web Engineering).pptLecture_1_Introduction (Web Engineering).ppt
Lecture_1_Introduction (Web Engineering).pptssuserb933d8
 
All about that reactive ui
All about that reactive uiAll about that reactive ui
All about that reactive uiPaul van Zyl
 

Similar to Building Scalable JS Apps with Marionette (20)

Understanding Microservices
Understanding Microservices Understanding Microservices
Understanding Microservices
 
ADUF - Adaptable Design Up Front
ADUF -  Adaptable Design Up FrontADUF -  Adaptable Design Up Front
ADUF - Adaptable Design Up Front
 
Microservices
MicroservicesMicroservices
Microservices
 
Александр Белецкий "Архитектура Javascript приложений"
 Александр Белецкий "Архитектура Javascript приложений" Александр Белецкий "Архитектура Javascript приложений"
Александр Белецкий "Архитектура Javascript приложений"
 
Migrating from Java EE to cloud-native Reactive systems
Migrating from Java EE to cloud-native Reactive systemsMigrating from Java EE to cloud-native Reactive systems
Migrating from Java EE to cloud-native Reactive systems
 
Migrating From Java EE To Cloud-Native Reactive Systems
Migrating From Java EE To Cloud-Native Reactive SystemsMigrating From Java EE To Cloud-Native Reactive Systems
Migrating From Java EE To Cloud-Native Reactive Systems
 
Over view of software artitecture
Over view of software artitectureOver view of software artitecture
Over view of software artitecture
 
MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.MicroserviceArchitecture in detail over Monolith.
MicroserviceArchitecture in detail over Monolith.
 
Large-Scale JavaScript Development
Large-Scale JavaScript DevelopmentLarge-Scale JavaScript Development
Large-Scale JavaScript Development
 
MICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptxMICROSERVICES ARCHITECTURE unit -2.pptx
MICROSERVICES ARCHITECTURE unit -2.pptx
 
Patterns
PatternsPatterns
Patterns
 
System design process.pptx
System design process.pptxSystem design process.pptx
System design process.pptx
 
Software Architecture for Agile Development
Software Architecture for Agile DevelopmentSoftware Architecture for Agile Development
Software Architecture for Agile Development
 
An overview of Scalable Web Application Front-end
An overview of Scalable Web Application Front-endAn overview of Scalable Web Application Front-end
An overview of Scalable Web Application Front-end
 
Micronaut Framework Guide Framework Basics and Fundamentals.pdf
Micronaut Framework Guide Framework Basics and Fundamentals.pdfMicronaut Framework Guide Framework Basics and Fundamentals.pdf
Micronaut Framework Guide Framework Basics and Fundamentals.pdf
 
Fad-Free Architecture
Fad-Free ArchitectureFad-Free Architecture
Fad-Free Architecture
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
Mobile app-and-microservices-with-ibm-cloud
Mobile app-and-microservices-with-ibm-cloudMobile app-and-microservices-with-ibm-cloud
Mobile app-and-microservices-with-ibm-cloud
 
Lecture_1_Introduction (Web Engineering).ppt
Lecture_1_Introduction (Web Engineering).pptLecture_1_Introduction (Web Engineering).ppt
Lecture_1_Introduction (Web Engineering).ppt
 
All about that reactive ui
All about that reactive uiAll about that reactive ui
All about that reactive ui
 

Building Scalable JS Apps with Marionette

  • 1. Composite Architecture with Marionette Building a scalable javascript application
  • 2. Problems. • Managing UI interactions gets complex very quickly • UI interactions have a way of coupling everything together • Having a page not reload means significant parts of it can change many times, and everything else still needs to work.
  • 3. Solution (sound architecture). • "The key is to acknowledge from the start that you have no idea how this will grow. When you accept that you don't know everything, you begin to design the system defensively. You identify the key areas that may change, which often is very easy when you put a little bit of time into it. For instance, you should expect that any part of the app that communicates with another system will likely change, so you need to abstract that away." -Nicholas Zakas, author 'High-performance JavaScript websites' • "The more tied components are to each other, the less reusable they will be, and the more difficult it becomes to make changes to one without accidentally affecting another" - Rebecca Murphey, author of jQuery Fundamentals.
  • 4. "The secret to building large apps is never build large apps. Break your applications into small pieces. Then, assemble those testable, bite-sized pieces into your big application" - Justin Meyer, author JavaScriptMVC
  • 5. Marionette.Application • Application objects are all about managing environment by providing ways to start, stop, and provide functionality • Keeping applications isolated is key • An application can have many sub applications • There is no distinction between an “application” and an object
  • 6. Mediator Pattern • As soon as one class calls methods on another class, you introduce coupling. This is (usually) fine at the class level. • Modules are a higher level then classes, this type of coupling has higher cost for them. • Instead of direct interaction, a mediator provides a single thing everyone knows about, and its responsibility is to manage the messages between them
  • 8. The three communication mechanisms in Marionette • Commands Provide functionality to the application • Request/Response Ask for some type of value • Event Let the application know that something happened
  • 9. Commands • Useful when you want to provide functionality that will be handled at a single point, but could be triggered anywhere.
  • 10. Request / Response • Useful when you want to request some kind of information from another part of the application
  • 11. Events • Useful when you want to broadcast that something happened, and it could be something that many other modules are interested in.
  • 12. Common Application Structure
  • 13. The Application • Primary responsibility is to start and stop sub applications. • Mediates cross sub-application communication (if necessary) • Often responsible for managing views that trigger major shifts in what sub applications in play. • Often provides a super high level layout manager
  • 14. Sub Application • Often correlates to a “screen” • Responsible for doing what is required for screen changes • Mediates module communication • Responsible for managing layout, and pushes regions down to modules for them to use for their views
  • 15. Module • Provide a high level piece of functionality (like “The Sidebar”) • Usually visual, but doesn’t have to be • “End of the road”, this is what manages the objects that actually provide functionality
  • 16. Good Ideas • Don’t bind modules commands/responses directly to their implementations, have a controller in between them • The previous breakdown is not set in stone, the hierarchy should change based on the requirements of the system • Since modules are composable, a good approach is to start with one, and split it apart as more functionality are requirements develop
  • 17. Things to keep in mind • Eventing provides a high level of decoupling, with a cost of making code harder to follow. • Decoupling at a low level will usually result in as bad a mess as too much coupling at a high level • OO is all about messages passing between networks of objects. All we are doing is adapting what we do in the small to make it appropriate for large scale design.
  • 18. Further Reading • Enterprise Integration Patterns - the “bible” of large scale design http://www.eaipatterns.com/ • Patterns for Large Scale Javascript Application Archetecture by Addy Osmani - http:// addyosmani.com/largescalejavascript/ • BBCloneMail - Marionette sample application https://github.com/derickbailey/bbclonemail

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n