jsfoo submission

23
Backbone, Marionette and Jasmine: A Game Changing Combination

Upload: harshit-jain

Post on 17-Aug-2015

84 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: JSFoo Submission

Backbone, Marionette and Jasmine: A Game Changing Combination

Page 2: JSFoo Submission

About Us

• Neha Singhal – Developer at Adobe. – Active in web development and UI for the past 2.5 years. – Likes solving interesting problems involving UX, cross-browser issues and maintainability

of code. – On a personal front, an avid dancer, loves to travel and is a big fan of animated movies.

• Harshit Jain – Developer at Adobe. – Web developer for 2 years with a passion for good UI/UX. – Likes solving usability and performance issues with his team. – Enjoys music and playing his guitar in his free time. – Loves hacking away on new libraries and frameworks, trying to figure out if he can use it

for his next project.

Page 3: JSFoo Submission
Page 4: JSFoo Submission

Why Backbone?

• Flexible• Un-opinionated• Models• Collections• Separates data from

your view• Modular

Page 5: JSFoo Submission

Backbone : Bring it on!!

• Model : Handles business logic and data

• Collection : Array of models

• View : User Interface

• Event : Actions on UI elements

• Routing : Navigation to application sub-modules

Page 6: JSFoo Submission

What Backbone Lacks…

• Life Cycle Management• Handling Zombie Views

• Complex View Management• Messaging Channels

Page 7: JSFoo Submission

… We Gain With Marionette

• Life Cycle Management• Handling Zombie Views

• Complex View Management• Messaging Channels

Page 8: JSFoo Submission

View: Life In The Fast Lane

INITIALIZE

RENDER

DESTROY

ATTACH

SHOW

Page 9: JSFoo Submission

View Management

• Item View• Collection View• Composite View• Layout View

ITEM VIEW

COLLECTION VIEW

LAYOUT VIEW

COMPOSITE VIEW

Page 10: JSFoo Submission

Item View

• View that represents a single item.

ITEM VIEW

COLLECTION VIEW

LAYOUT VIEW

COMPOSITE VIEW

Page 11: JSFoo Submission

Collection View

• Collection of multiple item views.

ITEM VIEW

COLLECTION VIEW

LAYOUT VIEW

COMPOSITE VIEW

Page 12: JSFoo Submission

Composite View

• Collection View with a template.

ITEM VIEW

COLLECTION VIEW

LAYOUT VIEW

COMPOSITE VIEW

Page 13: JSFoo Submission

Layout View

• Big Daddy of all views• Contains multiple

regions• A region can be

mapped to a view module

ITEM VIEW

COLLECTION VIEW

LAYOUT VIEW

COMPOSITE VIEW

Page 14: JSFoo Submission

Reusable Components

• Whaaaaaaaatt!!!! Is it really possible ??

Page 15: JSFoo Submission

Reusable Components

• Marionette by design treats all views as small, reusable entities.

• Views consist of– A Model/A Collection– A Template– Accompanying styling– Events

• Marionette conveniently bundles all these together so that they can be reused as many times as a developer wants

Page 16: JSFoo Submission

Reusable Components

• Method and procedure to achieve reusability in Marionette:– Attach view to a region

That’s it…Seriously!!

Page 17: JSFoo Submission

Central Messaging Channel

Page 18: JSFoo Submission

Plug And Play

It’s not magic.. Ok, maybe a little

Page 19: JSFoo Submission

Plug And Play

• Marionette detaches the code for the View from the business logic

• Painful UI modifications will now be a thing of the past

• Just switch the UI template and all the underlying logic works as before

Page 20: JSFoo Submission
Page 21: JSFoo Submission

Jasmine is..

• Javascript Testing Framework• Independent of browsers, DOM • Supports multiple javascript frameworks• Headless running out of the box• Easy to use• Clean Syntax

Page 22: JSFoo Submission

So let’s see what we’re up against

• Suite : to describe a section of your code

• Specs: it creates a new spec

• Expectations : what you expect the code block to do

Page 23: JSFoo Submission

So let’s see what we’re up against

• Matchers : utility functions– toEqual– toMatch– toBeTruthy– And the list goes on and on