Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Best Practices for Enterprise JavaScript Applic...

Arthur Kay
November 14, 2013

Best Practices for Enterprise JavaScript Applications

Many times looking at someone else’s code will trigger ideas of your own. That said, code reviews are sometimes fun… but more often frustrating. This webinar will show you a number of common mistakes and provide guidance on how to avoid them.

Join code gurus Art Kay, Solutions Architect at Sencha, and Jay Garcia, CTO at Modus Create, and learn how to bring your code to the next level.

Arthur Kay

November 14, 2013
Tweet

More Decks by Arthur Kay

Other Decks in Programming

Transcript

  1. Arthur Kay •  Solutions Architect @ Sencha, Inc. •  Web

    Development ~15 years •  www.akawebdesign.com •  @arthurakay
  2. Jay Garcia •  CTO @ Modus Create •  Author • 

    Ext JS in Action •  Sencha Touch in Action •  www.moduscreate.com •  @modusjesus
  3. Best Practice •  Use JSLint (or something else) •  JSHint

    •  Esprima •  …and many more… •  AUTOMATE!
  4. Nesting callbacks == nightmare •  Difficult to •  Read • 

    Comprehend •  Follow •  Debug •  Code “pyramids” are just over-all bad practice
  5. Best Practice •  Organize your file system •  Files and

    folders should match namespacing •  MVC (or something) •  Abstraction! •  Development loader / Production builder
  6. Best Practice •  Comment top-level structures •  Use Meaningful names

    •  “self documenting” code •  Add notes whenever logic is not obvious •  Build your docs into a searchable tool •  JSDuck •  …other tools…
  7. Truthy and Falsy •  When using “==“ or “!=“, JavaScript

    has room to coerce values •  Tests are boiled down to “Falsy” and “Truthy” •  Process is called coercion
  8. Best Practice •  Lazy initialization •  Add items/views only when

    necessary •  Lazy rendering •  Save the browser some time! •  Reuse things •  Save yourself some time!
  9. Two rules for “this” •  When a function is executed

    via a var reference, the default execution context (“this”) is “window. •  When a function is executed via an object key, the execution context (“this”) is the object.
  10. The “var” rule •  When a function is executed via

    a var reference, the default execution context (“this”) is “window”.
  11. The object “key” rule •  When a function is executed

    via an object key, the execution context (“this”) is that object.
  12. Two rules for “this” (review) •  When a function is

    executed via a var reference, the default execution context (“this”) is “window. •  When a function is executed via an object key, the execution context (“this”) is the object.
  13. Additional Resources •  “Maintainable JavaScript” by Nicholas Zakas •  http://www.slideshare.net/nzakas/maintainable-javascript-2012

    •  “Code Conventions for JS” by Douglass Crockford •  http://javascript.crockford.com/code.html •  “JavaScript Performance Tips & Tricks” by Grgur Grisogono •  http://moduscreate.com/javascript-performance-tips-tricks/