Download - ZombieCode
![Page 1: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/1.jpg)
TALK
![Page 2: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/2.jpg)
Zombie Code
![Page 3: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/3.jpg)
Zombie Codehow to survive a Javascript
Zombiecodeapocalypse
![Page 4: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/4.jpg)
First things first
my name is @cedmax
I work for Shazam
I organize conferences with From The Front
![Page 5: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/5.jpg)
DISCLAIMER
![Page 6: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/6.jpg)
DISCLAIMER
I’m strongly opinionated
![Page 7: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/7.jpg)
DISCLAIMER
I’m strongly opinionated
it’s a gift and a curse
![Page 8: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/8.jpg)
BasicallyZombies?
![Page 9: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/9.jpg)
BasicallyZombies?
![Page 10: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/10.jpg)
Zombies!
“Brains, BRAINS, BRains, brains, BRAINS.BRaiNS, brains, Brains, BRAINS, BRains,
brains, BRAINS.BRAINS, BRains, brains, BRAINS, brains.”
Ryan Mecum
![Page 11: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/11.jpg)
ZOMBIE CODE?
![Page 12: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/12.jpg)
it’s not dead code
http://alfasin.com/i-see-dead-code-homage-for-intellij-idea/
![Page 13: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/13.jpg)
How to identifyZombie CODE?
![Page 14: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/14.jpg)
What I can tell is..
![Page 15: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/15.jpg)
It may seems harmless
http://couchpotatofiles.wordpress.com/2012/03/20/the-walking-dead-ups-the-death-count-and-the-ratings/
![Page 16: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/16.jpg)
http://couchpotatofiles.wordpress.com/2012/03/20/the-walking-dead-ups-the-death-count-and-the-ratings/
but it’s NOT
![Page 17: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/17.jpg)
and it will, eventually
http://imgur.com/r/SRDBroke/JimqK
CODE
![Page 18: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/18.jpg)
during estimation
![Page 19: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/19.jpg)
during debugging
![Page 20: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/20.jpg)
during development
![Page 21: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/21.jpg)
It is dumb code that makes you dumb as well
![Page 22: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/22.jpg)
Hopefully it’s not too late
http://tacticaltshirts.com/shop/shirt-zombies-eat-brains/
![Page 23: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/23.jpg)
What's that smell?
Zombies smell worse than anything you can imagine
Lilith Saintcrow, Strange Angels
![Page 24: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/24.jpg)
TIp #1
Code should be appealing
![Page 25: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/25.jpg)
function validate( options ) {
// if nothing is selected, return nothing; can't chain anyway if ( !this.length ) { if ( options && options.debug && window.console ) { console.warn( "Nothing selected, can't validate, returning nothing." ); } return; }
// check if a validator for this form was already created var validator = $.data( this[0], "validator" ); if ( validator ) { return validator; }
// Add novalidate tag if HTML5. this.attr( "novalidate", "novalidate" );
validator = new $.validator( options, this[0] ); $.data( this[0], "validator", validator );
if ( validator.settings.onsubmit ) {
this.validateDelegate( ":submit", "click", function( event ) { if ( validator.settings.submitHandler ) {
validator.submitButton = event.target; }
![Page 26: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/26.jpg)
// allow suppressing validation by adding a cancel class to the submit button
if ( $(event.target).hasClass("cancel") ) { validator.cancelSubmit = true; }
// allow suppressing validation by adding the html5 formnovalidate attribute to the submit button if ( $(event.target).attr("formnovalidate") !== undefined ) { validator.cancelSubmit = true; } });
// validate the form on submit this.submit( function( event ) { if ( validator.settings.debug ) { // prevent form submit to be able to see console output event.preventDefault(); } function handle() { var hidden; if ( validator.settings.submitHandler ) { if ( validator.submitButton ) { // insert a hidden input as a replacement for the missing submit button hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val( $(validator.submitButton).val() ).appendTo(validator.currentForm); }
![Page 27: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/27.jpg)
validator.settings.submitHandler.call( validator, validator.currentForm, event );
if ( validator.submitButton ) { // and clean up afterwards; thanks to no-block-scope, hidden can be referenced hidden.remove(); } return false; } return true; }
// prevent submit for invalid forms or custom submit handlers if ( validator.cancelSubmit ) { validator.cancelSubmit = false; return handle(); } if ( validator.form() ) { if ( validator.pendingRequest ) { validator.formSubmitted = true; return false; } return handle(); } else { validator.focusInvalid(); return false; } }); }
return validator;}
![Page 28: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/28.jpg)
HOW LONG IS THAT?
![Page 29: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/29.jpg)
function validate( options ) {
// if nothing is selected, return nothing; can't chain anyway if ( !this.length ) { if ( options && options.debug && window.console ) { console.warn( "Nothing selected, can't validate, returning nothing." ); } return; }
// check if a validator for this form was already created var validator = $.data( this[0], "validator" ); if ( validator ) { return validator; }
// Add novalidate tag if HTML5. this.attr( "novalidate", "novalidate" );
validator = new $.validator( options, this[0] ); $.data( this[0], "validator", validator );
if ( validator.settings.onsubmit ) {
this.validateDelegate( ":submit", "click", function( event ) { if ( validator.settings.submitHandler ) { validator.submitButton = event.target; } // allow suppressing validation by adding a cancel class to the submit button if ( $(event.target).hasClass("cancel") ) { validator.cancelSubmit = true; }
// allow suppressing validation by adding the html5 formnovalidate attribute to the submit button if ( $(event.target).attr("formnovalidate") !== undefined ) { validator.cancelSubmit = true; } });
![Page 30: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/30.jpg)
// validate the form on submit this.submit( function( event ) { if ( validator.settings.debug ) { // prevent form submit to be able to see console output event.preventDefault(); } function handle() { var hidden; if ( validator.settings.submitHandler ) { if ( validator.submitButton ) { // insert a hidden input as a replacement for the missing submit button hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val( $(validator.submitButton).val() ).appendTo(validator.currentForm); } validator.settings.submitHandler.call( validator, validator.currentForm, event ); if ( validator.submitButton ) { // and clean up afterwards; thanks to no-block-scope, hidden can be referenced hidden.remove(); } return false; } return true; }
// prevent submit for invalid forms or custom submit handlers if ( validator.cancelSubmit ) { validator.cancelSubmit = false; return handle(); } if ( validator.form() ) { if ( validator.pendingRequest ) { validator.formSubmitted = true; return false; } return handle(); } else { validator.focusInvalid(); return false; } }); }
return validator;}
![Page 31: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/31.jpg)
14 (FOURTEEN!) ifs
![Page 32: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/32.jpg)
function validate( options ) {
// if nothing is selected, return nothing; can't chain anyway if ( !this.length ) { if ( options && options.debug && window.console ) { console.warn( "Nothing selected, can't validate, returning nothing." ); } return; }
// check if a validator for this form was already created var validator = $.data( this[0], "validator" ); if ( validator ) { return validator; }
// Add novalidate tag if HTML5. this.attr( "novalidate", "novalidate" );
validator = new $.validator( options, this[0] ); $.data( this[0], "validator", validator );
if ( validator.settings.onsubmit ) {
this.validateDelegate( ":submit", "click", function( event ) { if ( validator.settings.submitHandler ) { validator.submitButton = event.target; } // allow suppressing validation by adding a cancel class to the submit button if ( $(event.target).hasClass("cancel") ) { validator.cancelSubmit = true; }
// allow suppressing validation by adding the html5 formnovalidate attribute to the submit button if ( $(event.target).attr("formnovalidate") !== undefined ) { validator.cancelSubmit = true; } });
![Page 33: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/33.jpg)
// validate the form on submit this.submit( function( event ) { if ( validator.settings.debug ) { // prevent form submit to be able to see console output event.preventDefault(); } function handle() { var hidden; if ( validator.settings.submitHandler ) { if ( validator.submitButton ) { // insert a hidden input as a replacement for the missing submit button hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val( $(validator.submitButton).val() ).appendTo(validator.currentForm); } validator.settings.submitHandler.call( validator, validator.currentForm, event ); if ( validator.submitButton ) { // and clean up afterwards; thanks to no-block-scope, hidden can be referenced hidden.remove(); } return false; } return true; }
// prevent submit for invalid forms or custom submit handlers if ( validator.cancelSubmit ) { validator.cancelSubmit = false; return handle(); } if ( validator.form() ) { if ( validator.pendingRequest ) { validator.formSubmitted = true; return false; } return handle(); } else { validator.focusInvalid(); return false; } }); }
return validator;}
![Page 34: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/34.jpg)
are comments a bad thing?
![Page 35: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/35.jpg)
TIp #2
Code should talk to you
![Page 36: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/36.jpg)
_$ = (function(_) { return { pub: function(a, b, c, d) { for (d=-1, c=[].concat(_[a]); c[++d];) c[d](b) }, sub: function(a, b) { (_[a] || (_[a] = [])).push(b) } }})({})
![Page 37: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/37.jpg)
_$ = (function(_) { return { pub: function(a, b, c, d) { for (d=-1, c=[].concat(_[a]); c[++d];) c[d](b) }, sub: function(a, b) { (_[a] || (_[a] = [])).push(b) } }})({})
#140bytes
![Page 38: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/38.jpg)
_$ = (function() { var registered = {};
return {
pub: function(event, memo) { if (registered[event] instanceof Array){ var handlers = [].concat(registered[event]);
for (var i=0, handler; (handler = handlers[i]); i++){ handler.call(this, memo); } } }, sub: function(event, handler) { if (typeof registered[event] === "undefined"){ registered[event] = []; } registered[event].push(handler); }
};})();
![Page 39: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/39.jpg)
don’t use comments as an excuse to write bad code
![Page 40: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/40.jpg)
//used translate3d to trigger hardware acceleration in webViews//http://www.youtube.com/watch?v=IKl78ZgJzm4.animated { translate: translate3d(0,0,0)}
/** * Returns a unique ID for use in HTML id attribute. * @param {String/Number} nr A name or number of the ID. * @param {String} [prefix="id-"] The prefix for the ID. * @return {String} the new ID */function createId(nr, prefix){ //TODO implementation}
![Page 41: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/41.jpg)
//used translate3d to trigger hardware acceleration in webViews//http://www.youtube.com/watch?v=IKl78ZgJzm4.animated { translate: translate3d(0,0,0)}
/** * Returns a unique ID for use in HTML id attribute. * @param {String/Number} nr A name or number of the ID. * @param {String} [prefix="id-"] The prefix for the ID. * @return {String} the new ID */function createId(nr, prefix){ //TODO implementation}
un-avoidable
hacks explanation
![Page 42: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/42.jpg)
//used translate3d to trigger hardware acceleration in webViews//http://www.youtube.com/watch?v=IKl78ZgJzm4.animated { translate: translate3d(0,0,0)}
/** * Returns a unique ID for use in HTML id attribute. * @param {String/Number} nr A name or number of the ID. * @param {String} [prefix="id-"] The prefix for the ID. * @return {String} the new ID */function createId(nr, prefix){ //TODO implementation}
un-avoidable
hacks explanationAUTOMATED DOC
GENERATION
![Page 43: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/43.jpg)
//used translate3d to trigger hardware acceleration in webViews//http://www.youtube.com/watch?v=IKl78ZgJzm4.animated { translate: translate3d(0,0,0)}
/** * Returns a unique ID for use in HTML id attribute. * @param {String/Number} nr A name or number of the ID. * @param {String} [prefix="id-"] The prefix for the ID. * @return {String} the new ID */function createId(nr, prefix){ //TODO implementation}
un-avoidable
hacks explanationAUTOMATED DOC
GENERATION
TODOs
![Page 44: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/44.jpg)
TIp #3
Code should have boundaries
![Page 45: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/45.jpg)
Single responsibility
principle
your best tool against Zombie Code
since1902(guaranteed 20 years)
![Page 46: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/46.jpg)
No global pollution
http://leosabanganii.blogspot.co.uk/2012/10/zombie-dressed-activists-protest.html
![Page 47: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/47.jpg)
No coupling
http://leosabanganii.blogspot.co.uk/2012/10/zombie-dressed-activists-protest.htmlhttp
://aj
andc
harl
i.blo
gspo
t.co.
uk/2
011/
05/w
e-do
nt-d
o-de
ad-p
eopl
e.ht
ml
![Page 48: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/48.jpg)
worst case smell
![Page 49: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/49.jpg)
worst case smell
Long methods
![Page 50: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/50.jpg)
worst case smell
Long methods
Deep Level of Indentation
![Page 51: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/51.jpg)
worst case smell
Long methods
Deep Level of Indentation
Hard to tell what it does
![Page 52: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/52.jpg)
worst case smell
Long methods
Deep Level of Indentation
Hard to tell what it does
Lack of portability
![Page 53: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/53.jpg)
worst case smell
Long methods
Deep Level of Indentation
Hard to tell what it does
Lack of portability
Hardcoded style/templating
![Page 54: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/54.jpg)
worst case smell
Long methods
Deep Level of Indentation
Hard to tell what it does
Lack of portability
Hardcoded style/templating
Logic block duplication
![Page 55: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/55.jpg)
worst case smell
Long methods
Deep Level of Indentation
Hard to tell what it does
Lack of portability
Hardcoded style/templating
Logic block duplication
Callback hell
![Page 56: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/56.jpg)
And now what?
![Page 57: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/57.jpg)
Play cool!
![Page 58: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/58.jpg)
BasicallyQuarantine
![Page 59: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/59.jpg)
BasicallyQuarantine
![Page 60: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/60.jpg)
QUARANTINE
Most teams are trying to stop further spread only through quarantines. It's a good
short-term solution, but it won't prevent long-term population loss.
http://cdmx.it/quarantinequote
![Page 61: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/61.jpg)
The broken window
![Page 62: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/62.jpg)
“Don't leave "broken windows" (bad designs, wrong decisions, or poor code) unrepaired. Fix each one as soon as it is discovered.”Programming is insanely detail oriented, and perhaps this is why: if you're not on top of the details, the perception is that things are out of control, and it's only a matter of time before your project spins out of control. Maybe we should be sweating the small stuff.
Jeff Atwoodhttp://www.codinghorror.com/blog/2005/06/the-broken-window-theory.html
The broken window
![Page 63: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/63.jpg)
Maybe we should be sweating the small stuff.
Jeff Atwoodhttp://www.codinghorror.com/blog/2005/06/the-broken-window-theory.html
The broken window
![Page 64: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/64.jpg)
Isolate the Zombies
![Page 65: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/65.jpg)
define style guidelines
![Page 66: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/66.jpg)
function Zombie(personName) { function do_something() { console.log(personName + " just ate a brain!"); }
return { doSomethingZombiesDo: do_something };
}
var adam = new Zombie("Adam");adam.doSomethingZombiesDo();
![Page 67: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/67.jpg)
function Zombie(personName) { function do_something() { console.log(personName + " just ate a brain!"); }
return { doSomethingZombiesDo: do_something };
}
var adam = new Zombie("Adam");adam.doSomethingZombiesDo();
![Page 68: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/68.jpg)
function Zombie(personName) { function do_something() { console.log(personName + " just ate a brain!"); }
return { doSomethingZombiesDo: do_something };
}
var adam = new Zombie("Adam");adam.doSomethingZombiesDo();
![Page 69: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/69.jpg)
function Zombie(personName) { function do_something() { console.log(personName + " just ate a brain!"); }
return { doSomethingZombiesDo: do_something };
}
var adam = new Zombie("Adam");adam.doSomethingZombiesDo();
![Page 70: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/70.jpg)
define style guidelines
![Page 71: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/71.jpg)
start linting your code
![Page 72: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/72.jpg)
Inversion of control freakness
AM I A CONTROL FREAK?
![Page 73: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/73.jpg)
start testing your code
![Page 74: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/74.jpg)
Unit or Functional?
![Page 75: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/75.jpg)
Do both
![Page 76: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/76.jpg)
What to test
Unit testing is supposed to test a
single atomic “unit” of functionality without
dependencies on anything else
![Page 77: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/77.jpg)
What to test
Unit testing is supposed to test a
single atomic “unit” of functionality without
dependencies on anything else
This is where you start to run into serious
dependency problems due to the interrelation
HTML and CSS
![Page 78: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/78.jpg)
What to test
Unit testing is supposed to test a
single atomic “unit” of functionality without
dependencies on anything else
This is where you start to run into serious
dependency problems due to the interrelation
HTML and CSS
What do you test? Usually how the user interface responds to
user input. Actually, the realm of
functional testing
![Page 79: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/79.jpg)
No matter which toolset
Grunt
PhantomJS
JsTestDriver
Buster.js
Karma
Chutzpah
Testem
Qunit
Mocha
Jasmine
![Page 80: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/80.jpg)
No matter which toolset
Grunt
PhantomJS
JsTestDriver
Buster.js
Karma
Chutzpah
Testem
Qunit
Mocha
Jasmine
![Page 81: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/81.jpg)
As long as it can be automated
share
identify
build
make it continuous
![Page 82: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/82.jpg)
Make it part of the process
![Page 83: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/83.jpg)
Make it part of the process
http://rosarioconsulting.net/inspiredtoeducate/?p=706 http://powerbuilder.us/
Estimate testing
http://malyn.edublogs.org/2011/10/16/process-tools-people/
![Page 84: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/84.jpg)
Make it part of the process
Do code review
http://rosarioconsulting.net/inspiredtoeducate/?p=706 http://powerbuilder.us/
http://malyn.edublogs.org/2011/10/16/process-tools-people/
![Page 85: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/85.jpg)
Make it part of the process
http://rosarioconsulting.net/inspiredtoeducate/?p=706 http://powerbuilder.us/
Involve people
http://malyn.edublogs.org/2011/10/16/process-tools-people/
![Page 86: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/86.jpg)
Fear the living? DON’T
![Page 87: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/87.jpg)
The team
![Page 88: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/88.jpg)
DEVOPS PRODUCT OWNER
qa
![Page 89: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/89.jpg)
QA
![Page 90: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/90.jpg)
QA
Crucial role in the process
![Page 91: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/91.jpg)
QA
Crucial role in the process
Quality should be your goal too
![Page 92: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/92.jpg)
QA
Crucial role in the process
Quality should be your goal too
Get help for functional test coverage not to screw up refactoring
![Page 93: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/93.jpg)
Devops
![Page 94: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/94.jpg)
Devops
The tough guy
![Page 95: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/95.jpg)
Devops
The tough guy
It could be hard to deal with
![Page 96: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/96.jpg)
Devops
The tough guy
It could be hard to deal with
Get help setting up the automated process
![Page 97: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/97.jpg)
Product owner
![Page 98: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/98.jpg)
Product owner
The less interested in code itself
![Page 99: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/99.jpg)
Product owner
The less interested in code itself
Bring numbers, not theories
![Page 100: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/100.jpg)
Product owner
The less interested in code itself
Bring numbers, not theories
Get help not wasting time, staying focused on functionalities
![Page 101: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/101.jpg)
Others in the team
![Page 102: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/102.jpg)
juniorsexternal lobbyist
![Page 103: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/103.jpg)
Juniors
![Page 104: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/104.jpg)
Juniors
Pair with them, code review their (and your) code
![Page 105: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/105.jpg)
Juniors
Pair with them, code review their (and your) code
Involve them during the whole process definition
![Page 106: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/106.jpg)
Juniors
Pair with them, code review their (and your) code
Involve them during the whole process definition
Get help keeping things easy and accessible
![Page 107: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/107.jpg)
Lobbyists
![Page 108: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/108.jpg)
Lobbyists
They will slow you down, your brain will be more prone to be eaten
![Page 109: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/109.jpg)
Lobbyists
They will slow you down, your brain will be more prone to be eaten
Redirect them to the product owner
![Page 110: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/110.jpg)
BasicallyKILL ‘EM ALL (AGAIN?)
![Page 111: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/111.jpg)
BasicallyKILL ‘EM ALL (AGAIN?)
![Page 112: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/112.jpg)
KILL ‘EM ALL (AGAIN?)
“Nothing is impossible to kill.”Mira Grant, Feed
![Page 113: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/113.jpg)
but
![Page 114: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/114.jpg)
“Without requirements or design, programming is the art of adding bugs to an empty text file”
Louis Srygley
Design for your goal
![Page 115: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/115.jpg)
Design for your goal
![Page 116: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/116.jpg)
Modular Architecture
![Page 117: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/117.jpg)
![Page 118: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/118.jpg)
Scalable JavaScript Application
Architecture
by Nicholas Zakas
![Page 119: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/119.jpg)
![Page 120: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/120.jpg)
![Page 121: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/121.jpg)
core.register("module-name", function(sandbox){
return { init:function(){ }, destroy:function(){ } };
});
![Page 122: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/122.jpg)
core.register("module-name", function(sandbox){
return { init:function(){ }, destroy:function(){ } };
});
![Page 123: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/123.jpg)
core.register("module-name", function(sandbox){
return { init:function(){ }, destroy:function(){ } };
});
![Page 124: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/124.jpg)
![Page 125: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/125.jpg)
![Page 126: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/126.jpg)
core.register("module-name", function(sandbox){
return { init:function(){ var user = sandbox.getUser(); }, destroy:function(){ } };
});
![Page 127: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/127.jpg)
core.register("module-name", function(sandbox){
return { init:function(){ var user = sandbox.getUser(); }, destroy:function(){ } };
});
![Page 128: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/128.jpg)
![Page 129: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/129.jpg)
core.register('module-name', function(sandbox){
return { init:function(config){ console.log(config.id); } };
});
core.configure('module-name', { id: 'container',});
core.start('module-name');
core.stop('module-name');
![Page 130: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/130.jpg)
core.register('module-name', function(sandbox){
return { init:function(config){ console.log(config.id); } };
});
core.configure('module-name', { id: 'container',});
core.start('module-name');
core.stop('module-name');
![Page 131: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/131.jpg)
core.register('module-name', function(sandbox){
return { init:function(config){ console.log(config.id); } };
});
core.configure('module-name', { id: 'container',});
core.start('module-name');
core.stop('module-name');
![Page 132: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/132.jpg)
core.register('module-name', function(sandbox){
return { init:function(config){ console.log(config.id); } };
});
core.configure('module-name', { id: 'container',});
core.start('module-name');
core.stop('module-name');
![Page 133: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/133.jpg)
core.register('module-name', function(sandbox){
return { init:function(config){ console.log(config.id); } };
});
core.configure('module-name', { id: 'container',});
core.start('module-name');
core.stop('module-name');
![Page 134: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/134.jpg)
core.register('module-name', function(sandbox){
return { init:function(config){ console.log(config.id); } };
});
core.configure('module-name', { id: 'container',});
core.start('module-name');
core.stop('module-name');
![Page 135: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/135.jpg)
![Page 136: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/136.jpg)
![Page 137: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/137.jpg)
Event Driven Pattern
![Page 138: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/138.jpg)
core.register("module-name", function(sandbox){ return { init:function(){ sandbox.layer("an error occured"); } };});
![Page 139: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/139.jpg)
core.register("module-name", function(sandbox){ return { init:function(){ sandbox.layer("an error occured"); } };});
![Page 140: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/140.jpg)
sandbox.layer("an error occured");
![Page 141: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/141.jpg)
sandbox.publish("error", { msg: "an error occured"});
![Page 142: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/142.jpg)
sandbox.publish("error", { msg: "an error occured"});
core.register("errManager", function(sandbox){ return { init:function(){ sandbox.subscribe("error", function(err) { console.log(err.msg) }); } };});
![Page 143: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/143.jpg)
sandbox.publish("error", { msg: "an error occured"});
core.register("errManager", function(sandbox){ return { init:function(){ sandbox.subscribe("error", function(err) { console.log(err.msg) }); } };});
![Page 144: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/144.jpg)
sandbox.publish("error", { msg: "an error occured"});
core.register("errManager", function(sandbox){ return { init:function(){ sandbox.subscribe("error", function(err) { console.log(err.msg) }); } };});
![Page 145: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/145.jpg)
sandbox.publish("error", { msg: "an error occured"});
core.register("errManager", function(sandbox){ return { init:function(){ sandbox.subscribe("error", function(err) { console.log(err.msg) }); } };});
![Page 146: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/146.jpg)
sandbox.publish("error", { msg: "an error occured"});
core.register("errManager", function(sandbox){ return { init:function(){ sandbox.subscribe("error", function(err) { console.log(err.msg) }); } };});
![Page 147: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/147.jpg)
sandbox.publish("error", { msg: "an error occured"});
core.register("errManager", function(sandbox){ return { init:function(){ sandbox.subscribe("error", function(err) { console.log(err.msg) }); } };});
![Page 148: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/148.jpg)
sandbox.publish("error", { msg: "an error occured"});
core.register("errManager", function(sandbox){ return { init:function(){ sandbox.subscribe("error", function(err) { console.log(err.msg) }); } };});
![Page 149: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/149.jpg)
sandbox.publish("error", { msg: "an error occured"});
core.register("errManager", function(sandbox){ return { init:function(){ sandbox.subscribe("error", function(err) { console.log(err.msg) }); } };});
![Page 150: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/150.jpg)
sandbox.subscribe("error", function(payload){
console.log(payload.msg);
});
Advantages
![Page 151: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/151.jpg)
sandbox.subscribe("error", function(payload){
console.log(payload.msg);
});
Advantages
SEMANTIC
![Page 152: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/152.jpg)
sandbox.subscribe("error", function(payload){
console.log(payload.msg);
});
Advantages
SEMANTIC
flexibility
![Page 153: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/153.jpg)
Advantages
DECOUPLING
![Page 154: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/154.jpg)
“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.”
Nicholas Zakas
Overengineering?
![Page 155: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/155.jpg)
AMD
![Page 156: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/156.jpg)
icon by http://www.deleket.com/
jQuery
Mustache
Libraries Plugins Your scripts
![Page 157: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/157.jpg)
icon by http://www.deleket.com/
jQuery
Mustache
Libraries Plugins Your scripts
![Page 158: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/158.jpg)
<script src="jquery.min.js"></script><script src="mustache.js"></script>
<?php if ($env == "prod") : ?> <script src="my-code-bundle.js"></script><?php else: ?> <script src="jquery.plugin_1.js"></script> <script src="jquery.plugin_2.js"></script> <script src="my-code_1.js"></script> <script src="my-code_2.js"></script> <script src="my-code_3.js"></script> <script src="my-code_4.js"></script> <script src="my-code_5.js"></script><?php endif; ?>
![Page 159: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/159.jpg)
var MyNamespace = {};
MyNamespace.MyAwesomeLibrary = function() { //implementation};MyNamespace.AnotherCoolOne = function() { //implementation};MyNamespace.SlightlyCrappyLibrary = function() { //implementation};MyNamespace.BestLibEver = function() { //implementation};
![Page 160: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/160.jpg)
//API: define(id?, dependencies?, factory);
define("My-Module", ["Another-Module"], function(AnotherModule){ // Do Something });
one define to rule them all
![Page 161: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/161.jpg)
//API: define(id?, dependencies?, factory);
define("My-Module", ["Another-Module"], function(AnotherModule){ // Do Something });
one define to rule them all
![Page 162: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/162.jpg)
//app/config.jsdefine([], function() { return { url: "http://whatever.it/is/", debug: true };});
![Page 163: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/163.jpg)
//app/config.jsdefine([], function() { return { url: "http://whatever.it/is/", debug: true };});
//app/config.jsdefine({ url: "http://whatever.it/is/", debug: true});
![Page 164: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/164.jpg)
//app/config.jsdefine([], function() { return { url: "http://whatever.it/is/", debug: true };});
//app/config.jsdefine({ url: "http://whatever.it/is/", debug: true});
![Page 165: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/165.jpg)
//app/config.jsdefine([], function() { return { url: "http://whatever.it/is/", debug: true };});
//app/config.jsdefine({ url: "http://whatever.it/is/", debug: true});
![Page 166: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/166.jpg)
//app/myProduct.jsdefine(["app/config"], function(config) {
return function(id){ return { getProductUrl: function(){ var prodPath = config.url + "product/" + id; if (config.debug){ console.log(prodPath) } return prodPath; } }; };});
![Page 167: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/167.jpg)
//app/myProduct.jsdefine(["app/config"], function(config) {
return function(id){ return { getProductUrl: function(){ var prodPath = config.url + "product/" + id; if (config.debug){ console.log(prodPath) } return prodPath; } }; };});
![Page 168: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/168.jpg)
//app/myProduct.jsdefine(["app/config"], function(config) {
return function(id){ return { getProductUrl: function(){ var prodPath = config.url + "product/" + id; if (config.debug){ console.log(prodPath) } return prodPath; } }; };});
![Page 169: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/169.jpg)
//app/myProduct.jsdefine(["app/config"], function(config) {
return function(id){ return { getProductUrl: function(){ var prodPath = config.url + "product/" + id; if (config.debug){ console.log(prodPath) } return prodPath; } }; };});
![Page 170: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/170.jpg)
//app/myProduct.jsdefine(["app/config"], function(config) {
return function(id){ return { getProductUrl: function(){ var prodPath = config.url + "product/" + id; if (config.debug){ console.log(prodPath) } return prodPath; } }; };});
![Page 171: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/171.jpg)
//app/myProduct.jsdefine(["app/config"], function(config) {
return function(id){ return { getProductUrl: function(){ var prodPath = config.url + "product/" + id; if (config.debug){ console.log(prodPath) } return prodPath; } }; };});
![Page 172: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/172.jpg)
//app/myProduct.jsdefine(["app/config"], function(config) {
return function(id){ return { getProductUrl: function(){ var prodPath = config.url + "product/" + id; if (config.debug){ console.log(prodPath) } return prodPath; } }; };});
![Page 173: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/173.jpg)
//app/myProduct.jsdefine(["app/config"], function(config) {
return function(id){ return { getProductUrl: function(){ var prodPath = config.url + "product/" + id; if (config.debug){ console.log(prodPath) } return prodPath; } }; };});
![Page 174: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/174.jpg)
//app/myProduct.jsdefine(["app/config"], function(config) {
return function(id){ return { getProductUrl: function(){ var prodPath = config.url + "product/" + id; if (config.debug){ console.log(prodPath) } return prodPath; } }; };});
![Page 175: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/175.jpg)
<script data-main="app/main" src="require.js"></script>
![Page 176: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/176.jpg)
<script data-main="app/main" src="require.js"></script>
//app/main.jsrequire(["jQuery", "app/myProduct"], function($, Product) {
$(".product").on("click", function(){ var prodID = $(this).data("id"); var prod = new Product(prodID); document.location.href = prod.getProductUrl(); })
});
![Page 177: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/177.jpg)
<script data-main="app/main" src="require.js"></script>
//app/main.jsrequire(["jQuery", "app/myProduct"], function($, Product) {
$(".product").on("click", function(){ var prodID = $(this).data("id"); var prod = new Product(prodID); document.location.href = prod.getProductUrl(); })
});
![Page 178: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/178.jpg)
<script data-main="app/main" src="require.js"></script>
//app/main.jsrequire(["jQuery", "app/myProduct"], function($, Product) {
$(".product").on("click", function(){ var prodID = $(this).data("id"); var prod = new Product(prodID); document.location.href = prod.getProductUrl(); })
});
![Page 179: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/179.jpg)
<script data-main="app/main" src="require.js"></script>
//app/main.jsrequire(["jQuery", "app/myProduct"], function($, Product) {
$(".product").on("click", function(){ var prodID = $(this).data("id"); var prod = new Product(prodID); document.location.href = prod.getProductUrl(); })
});
![Page 180: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/180.jpg)
<script data-main="app/main" src="require.js"></script>
//app/main.jsrequire(["jQuery", "app/myProduct"], function($, Product) {
$(".product").on("click", function(){ var prodID = $(this).data("id"); var prod = new Product(prodID); document.location.href = prod.getProductUrl(); })
});
![Page 181: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/181.jpg)
Pulling all together
![Page 182: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/182.jpg)
define(function(){ 'use strict';
return function(sandbox){
//the logic of the module function doSomething(){ //do something }
return { init:function(config){ //the initialization code sandbox.subscribe('myEventName', doSomething) }, destroy: function(){ //optional destroy method } }; };});
![Page 183: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/183.jpg)
define(function(){ 'use strict';
return function(sandbox){
//the logic of the module function doSomething(){ //do something }
return { init:function(config){ //the initialization code sandbox.subscribe('myEventName', doSomething) }, destroy: function(){ //optional destroy method } }; };});
![Page 184: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/184.jpg)
define(function(){ 'use strict';
return function(sandbox){
//the logic of the module function doSomething(){ //do something }
return { init:function(config){ //the initialization code sandbox.subscribe('myEventName', doSomething) }, destroy: function(){ //optional destroy method } }; };});
![Page 185: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/185.jpg)
define(function(){ 'use strict';
return function(sandbox){
//the logic of the module function doSomething(){ //do something }
return { init:function(config){ //the initialization code sandbox.subscribe('myEventName', doSomething) }, destroy: function(){ //optional destroy method } }; };});
![Page 186: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/186.jpg)
define(function(){ 'use strict';
return function(sandbox){
//the logic of the module function doSomething(){ //do something }
return { init:function(config){ //the initialization code sandbox.subscribe('myEventName', doSomething) }, destroy: function(){ //optional destroy method } }; };});
![Page 187: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/187.jpg)
require(["akase"], function(core) {
core.start("module1"); core.start("module2", { config: { debug: true } });
core.start("module3", { event: "audio:stop" });
});
![Page 188: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/188.jpg)
require(["akase"], function(core) {
core.start("module1"); core.start("module2", { config: { debug: true } });
core.start("module3", { event: "audio:stop" });
});
![Page 189: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/189.jpg)
require(["akase"], function(core) {
core.start("module1"); core.start("module2", { config: { debug: true } });
core.start("module3", { event: "audio:stop" });
});
![Page 190: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/190.jpg)
require(["akase"], function(core) {
core.start("module1"); core.start("module2", { config: { debug: true } });
core.start("module3", { event: "audio:stop" });
});
![Page 191: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/191.jpg)
require(["akase"], function(core) {
core.start("module1"); core.start("module2", { config: { debug: true } });
core.start("module3", { event: "audio:stop" });
});
![Page 192: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/192.jpg)
ākāśe sanskrit for "in the sky"/"to the sky"
https://github.com/cedmax/akase
![Page 193: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/193.jpg)
No such this thing!
![Page 194: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/194.jpg)
BasicallyHappy Endings?
![Page 195: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/195.jpg)
BasicallyHappy Endings?
![Page 196: ZombieCode](https://reader031.vdocument.in/reader031/viewer/2022013003/546568dbaf7959045f8b726b/html5/thumbnails/196.jpg)
you are going to write zombie code
zombie code will always be out there
live with it, embrace it, have a strategy to deal with it