Silicon Valley Code Camp : October 8th and 9th, 2011.
Shawn Van Ittersum
AppJudo Inc.
About Shawn
Shawn is a web and mobile software entrepreneur, consultant, and instructor with over twenty years of UI design and development experience, including over 15 years of full-stack web application development.
Speaking Sessions
JavaScript Code Organization and Encapsulation
UPDATE - Slides now available at:
http://www.multiwidget.com/JavaScript_Organization_and_Encapsulation.pdf
Follow my new account on Twitter for JS, Ruby, HTML5, and productivity news.
Twitter handle: @svicalifornia
As front-end web applications grow, JavaScript code can become complex and difficult to modify and maintain. Global variables, functions, and objects often become interconnected in unanticipated ways, increasing the risk of unintended side effects with each future change. JavaScript code mixed into server-side HTML templates adds additional complexity that can be hard to follow.
This talk will present ideas for organizing, encapsulating, and simplifying JavaScript code, including:- creating JavaScript objects and classes with truly private members, using Douglas Crockford's module pattern and classical inheritance constructs provided by Dean Edward's Base.js, Prototype, and MooTools;
- abstracting JavaScript code from HTML templates, CSS styling, and the DOM;
- designing with polymorphism (duck typing) for code reuse and simplicity; and
- using JSLint to identify problems in your code before runtime.