Going "Web Scale" with JavaScript Polymorphism

2013 Jul09
T

he recent trend has been to push more and more work on to the client side as browser become more and more capable. This means that complexity of your javascript can get out of hand very quickly. Being able to scale simple piece up to handle complex and even specialized tasks is an important part of sound javascript application architecture.

One way to accomplish this is through simple polymorphism, or as in many Object Orient Orientated languages, Generic Programming. The general pattern is to have a single light class or module that has a standard set of methods which does nothing more than call methods of the same name on any number of other objects ( classes, modules, etc. )

For

Read More
filed under:  javascript amd polymorphism oop

Goin' Full Require: Turtles All The Way Down

2012 Nov14
N

ow that we are comfortable the syntax for creating and loading modules we need to set up configure **RequireJS** to load anything and everything we want for our applications. Luckily the configuration API for RequireJS is rather straight forward and allows for a lot of flexibility. Configuring RequireJS is a simple as passing it an Object literal.

var SiteName = require({ });

Pretty simple! The require function returns a configured instance of RequireJS so you can stash it in a variable and use it as the loader for a specific set of modules, or as it if were your applications primary name space. Now, there are 3 options in particular we are going to want to pay special attention to -

Read More
filed under:  javascript amd requirejs

Goin' Full Require: Moving To AMD

2012 Nov02
A

MD ( [Asyncronous Module Definition](http://wiki.commonjs.org/wiki/CommonJS) ) is a apart of the [CommonJS](http://www.commonjs.org/) movement. It aims to bring something to javasscript is very much needed in todays world of browser based applications. And that is the idea of modules. A logical way of breaking your apps into smaller, more logical peices and import dependencies only in the situations that you actually need them. [RequireJS](http://www.requirejs.org) is at the fore front of JavaScript Module loaders, and for good reason. When you start to dig into RequireJS, you'll find that it isn't just a fancy script loader, but more of a micro-framework for managing large JavaSscript Apps.

Make The Move

Its

Read More
filed under:  javascript amd requirejs modules

Case Study: Cross Browser Logging AMD Module

2012 Apr24
T

he console object, which allows developers to echo arbitrary pieces of data out to a console in the browser, is becoming a standard piece of equipment in most browsers. However, there are some browsers that do not have a console implemented, and leaving code that references the console object in browsers that do not have one will cause your javascript programs to die.

To normalize and remedy this pain point in development We will define a Log module to encapsulate the desired functionality. Or example will aim to mimic the api of the popular firebug development tool as well as provide a fallback for browsers that do not implement a logging console as well as for browsers that do

Read More
filed under:  log amd commonjs console requirejs