introducing applitude: simple module management
DESCRIPTION
TRANSCRIPT
![Page 1: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/1.jpg)
Introducing ApplitudeSimple Module Management
![Page 2: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/2.jpg)
Eric ElliottAuthor
"Programming JavaScript Applications"
![Page 3: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/3.jpg)
Modularity = Simplicity
![Page 4: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/4.jpg)
Avoid Complexity(don't build a large app!)
![Page 5: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/5.jpg)
Build Lots of Small Apps!(modules)
![Page 6: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/6.jpg)
Principles of
Modularity
![Page 7: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/7.jpg)
Principles of
Modularity(modules are...)
![Page 8: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/8.jpg)
Specialized
(do one thing)
![Page 9: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/9.jpg)
Independent
(don't dependon each other)
![Page 10: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/10.jpg)
Decomposable
(work inisolation)
![Page 11: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/11.jpg)
Recomposable
(work indifferent apps)
![Page 12: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/12.jpg)
Substitutable
(can swap modules)
![Page 13: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/13.jpg)
Module Interfaces
![Page 14: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/14.jpg)
"Program to an interface, not an implementation."
- Gang of Four
![Page 15: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/15.jpg)
Open / Closed Principle
![Page 16: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/16.jpg)
Open for
Extension
![Page 17: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/17.jpg)
Closed for
Modification(breaking changes)
![Page 18: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/18.jpg)
Communicate through
Mediator(event bus)
![Page 19: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/19.jpg)
Module FrameworkResponsibilities
![Page 20: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/20.jpg)
Namespacing
![Page 21: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/21.jpg)
Sandbox API
![Page 22: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/22.jpg)
Expose Environment
![Page 23: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/23.jpg)
Lifecycle
![Page 24: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/24.jpg)
Load Timing
![Page 25: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/25.jpg)
Define Module API
![Page 26: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/26.jpg)
Introducing Applitude(a module framework)
![Page 27: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/27.jpg)
An Applitude Module
// IIFE for encapsulation
(function (app) {// your code here
}(applitude));
![Page 28: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/28.jpg)
Namespace it...
(function (app) { // namespace should be a var var namespace = 'hello';}(applitude));
![Page 29: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/29.jpg)
Provide an API(function (app) { 'use strict'; var namespace = 'hello', api;
function hello() { return 'hello, world'; }
api = { hello: hello };
app.register(namespace, api);}(applitude));
![Page 30: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/30.jpg)
Register(function (app) { 'use strict'; var namespace = 'hello', api;
function hello() { return 'hello, world'; }
api = { hello: hello };
app.register(namespace, api);}(applitude));
![Page 31: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/31.jpg)
Sandbox API
app.register();app.environment // objectapp.deferred(); // also .when(), .queue(), ...app.o(); // prototypal ooapp.events();app.log();
![Page 32: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/32.jpg)
api = { load: load, render: render,
beforeRender: [promise, iou, eventually] };
runs early!(please don't block)
.load()
![Page 33: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/33.jpg)
api = { load: load, render: render,
beforeRender: [promise, iou, eventually] };
waits around...
.render()
![Page 34: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/34.jpg)
api = { load: load, render: render,
beforeRender: [promise, iou, eventually] };
for load...
.render()
![Page 35: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/35.jpg)
api = { load: load, render: render,
beforeRender: [promise, iou, eventually] };
and this stuff...
.beforeRender
![Page 36: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/36.jpg)
$(document).ready(function () { // Make this faster! // developer.yahoo.com/yslow});
and this guy
.beforeRender
![Page 37: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/37.jpg)
(function (app) { var namespace = 'sendMessage', api;
api = function sendMessage(message) { app.events.trigger('send_message.' +
namespace, message); };
app.register(namespace, api);}(applitude));
Modules should NOT call each other directly.
Use Events
![Page 38: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/38.jpg)
(function (app) { var namespace = 'messageLogger', api;
function subscribe() { app.events.on('send_message.*',
function (payload) { app.log(payload); }); }
// public interface api = { load: subscribe };
// this never has to change app.register(namespace, api);}(applitude));
Listen
![Page 39: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/39.jpg)
app.register();app.environment // object
app.deferred();app.when();app.o(); // prototypal oo...
Better Than Ice Cream
![Page 40: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/40.jpg)
Get the Sourcehttp://dilvie.github.com/applitude/
![Page 41: Introducing Applitude: Simple Module Management](https://reader034.vdocuments.net/reader034/viewer/2022051611/54b7a0714a795998738b4662/html5/thumbnails/41.jpg)
Get the Bookhttp://ericleads.com/javascript-applications/