{❴
frameworks
}❵
are generally
prescriptive
and sometimes
restrictive
:
Slide 17
Slide 17 text
{❴
libraries
}❵
are generally
focused
and
specific
:
Slide 18
Slide 18 text
backbone (13,619)
knockout (3,532)
meteor (8,144)
angular (8,449)
ember (6,610)
batman (1,321)
spine (2,336)
according to
frameworks libraries
canJS (569)
⤻
star count
Slide 19
Slide 19 text
backbone.js is
SJEJDVMPVTMZ
unopinionated
Slide 20
Slide 20 text
Models
Views
Events
Router
data & associated functions
Slide 21
Slide 21 text
Models
Views
Events
Router
data & associated functions
ui backed by a model
Slide 22
Slide 22 text
Models
Views
Events
Router
data & associated functions
ui backed by a model
bind & trigger custom events
Slide 23
Slide 23 text
Models
Views
Events
Router
data & associated functions
ui backed by a model
bind & trigger custom events
linkable URLs
Slide 24
Slide 24 text
refactoring
1st
step
Slide 25
Slide 25 text
everywhere
state stored
The Grinch.
meanest grinch of all.
function sayHello(){
var name = $('.name').text();
var desc = $('.desc').text();
return'Hello I’m '+ name +'The ' + desc;
}
sayHello();
Slide 26
Slide 26 text
backbone.js
var Animal = Backbone.Model.extend({
sayHello: function () {
var name = this.get('name');
return 'Hello, I am ' + name;
}
});
var animal = new Animal({name:'cat'});
animal.sayHello();
refactored to
focused
Backbone keeps it small
encapsulated
Backbone keeps it
Backbone keeps it
Slide 29
Slide 29 text
No content
Slide 30
Slide 30 text
No
Strength
Instructions
Slide 31
Slide 31 text
No
Weakne
Instructions
Slide 32
Slide 32 text
all it gives you is a base
to help you into the world of
well structured javascript
Slide 33
Slide 33 text
one thousand models
impossible to extend
one thousand views
what the hell
is going on
Slide 34
Slide 34 text
backbone
soup
Slide 35
Slide 35 text
wait...
shouldn’t mv
prevent the soup?
✯
WHAT
Slide 36
Slide 36 text
Presentation
Pa ern
ONLY
mv stars are
Slide 37
Slide 37 text
{❴ mv✯ can’t save us now }❵
Slide 38
Slide 38 text
unsuck
my backbone
Do I
how
Slide 39
Slide 39 text
can we build
scalable backbone
applications
Slide 40
Slide 40 text
how do people build
desktop applications
can we learn anything
Slide 41
Slide 41 text
composite
applications
Slide 42
Slide 42 text
The secret to building large
apps is never build large apps.
Break your application into
small pieces. Then, assemble
those testable, bite-sized
pieces into your big application ”
“
Justin Meyer, author JavaScriptMVC
Slide 43
Slide 43 text
Round u
Views
Models
into
Modules
Round u
Slide 44
Slide 44 text
How do you spot modules in a
crowded room?
Slide 45
Slide 45 text
MODULE㽉
Slide 46
Slide 46 text
MODULE
Slide 47
Slide 47 text
No content
Slide 48
Slide 48 text
Module
a small piece of functionality
Slide 49
Slide 49 text
Module
are decoupled from each other
Slide 50
Slide 50 text
Module
ask never take
Slide 51
Slide 51 text
Module
don't pollute the global scope
Slide 52
Slide 52 text
A change to this module:
Doesn't impact other modules
Slide 53
Slide 53 text
Put this module on a new page:
and it still works!
Slide 54
Slide 54 text
still play a part ...
presentation pa ern
Slide 55
Slide 55 text
⬌
How do these
modules work
together?
Slide 56
Slide 56 text
self organise
⬌
⬌
⬌
⬌
⬌
⬌
⬌
⬌
⬌
⬌
⬌
⬌
⬌
they could
Slide 57
Slide 57 text
⬌
⬌
⬌
BUGs!
I’m taking you all
down with me!
Slide 58
Slide 58 text
planes don't rule the runway
Slide 59
Slide 59 text
does
air traffic
control
no flips!
Slide 60
Slide 60 text
air traffic
⬌
control
Slide 61
Slide 61 text
Placement
Eventing
Start Up Lifecycle
A lication
Slide 62
Slide 62 text
Placement
Eventing
Start Up Lifecycle
A lication
Slide 63
Slide 63 text
Placement
Eventing
Start Up Lifecycle
A lication
Slide 64
Slide 64 text
Placement
Eventing
Start Up Lifecycle
A lication
fire up the engines
Slide 65
Slide 65 text
Placement
Eventing
Start Up Lifecycle
A lication
initial global setup
Slide 66
Slide 66 text
Placement
Eventing
Start Up Lifecycle
A lication
Slide 67
Slide 67 text
Placement
Eventing
Start Up Lifecycle
A lication
do we have permission to land? go ahead
Slide 68
Slide 68 text
Placement
Eventing
Start Up Lifecycle
A lication
publish & subscribe
to events
Slide 69
Slide 69 text
Placement
Eventing
Start Up Lifecycle
A lication
Slide 70
Slide 70 text
Placement
Eventing
Start Up Lifecycle
A lication
time to take off?
Not yet!
Slide 71
Slide 71 text
Placement
Eventing
Start Up Lifecycle
A lication
when is it safe for a
module to start
Slide 72
Slide 72 text
Placement
Eventing
Start Up Lifecycle
A lication
Slide 73
Slide 73 text
Placement
Eventing
Start Up Lifecycle
A lication
which runway?
that
runway
Slide 74
Slide 74 text
Placement
Eventing
Start Up Lifecycle
A lication
places modules inside
the application shell
Slide 75
Slide 75 text
Placement
Eventing
Start Up Lifecycle
A lication
Slide 76
Slide 76 text
focused modules
round up your features into
Slide 77
Slide 77 text
pub & sub
fire and forget
Slide 78
Slide 78 text
compose yourself
regain control
Slide 79
Slide 79 text
built this way
are flexible enough to
applications
accept change
Slide 80
Slide 80 text
can we build
backbone.js
this way?
applications
Slide 81
Slide 81 text
No content
Slide 82
Slide 82 text
into two parts
can be split
marionette
Slide 83
Slide 83 text
to backbone.js
mv✯
extensions
Slide 84
Slide 84 text
ItemView
CollectionView
Layout
mv✯ extensions
1
Slide 85
Slide 85 text
ItemView
CollectionView
Layout
mv✯ extensions
1
Slide 86
Slide 86 text
mv✯ extensions
1 ItemView
MyView = Backbone.Marionette.ItemView.extend({
template: "#some-template"
});
var view = new MyView({model: new FakeModel()});
view.render();
Composite Apps
2 Eventing
var vent = new Backbone.Wreqr.EventAggregator();
vent.on("foo", function(){
console.log("foo event");
});
//elsewhere in your app
vent.trigger("foo");
Composite Apps
2 Eventing
var reqres = new Backbone.Wreqr.RequestResponse();
reqres.setHandler("foo", function(){
return "foo requested. this is the response";
});
//elsewhere in your app
var result = reqres.request("foo");
console.log(result);
Composite Apps
2 Eventing
var commands = new Backbone.Wreqr.Commands();
commands.setHandler("foo", function(){
console.log("the foo command was executed");
});
//elsewhere in your app
commands.execute("foo");
tl;dr
they don’t help us write
scaleable
JavaScript a lication
Slide 134
Slide 134 text
tl;dr
we need to think beyond mv✯
Slide 135
Slide 135 text
tl;dr
large JavaScript applications
composed
from smaller parts
Slide 136
Slide 136 text
tl;dr
make your application dance
marionette.js
Slide 137
Slide 137 text
That it!
@ammeep
amy.palamounta.in
internet related activities:
greenbutton.com
backbonejs.org
marionettejs.com
lostechies.com/derickbailey
addyosmani.com/blog