Essential Javascript & Jquery Design Patterns - Addy Osmani
Essential Javascript & Jquery Design Patterns - Addy Osmani
Essential Javascript & Jquery Design Patterns - Addy Osmani
Foreword
I would like to thank Rebecca Murphy for inspiring me to open-source this mini-
book and release it for free download and distribution - making knowledge both
open and easily available is something we should all strive for where possible. I
would also like to extend my thanks to the very talented Alex Sexton who was
kind enough to be the technical reviewer for this publication. I hope that it helps
you learn more about design patterns and the usefulness of their application to
JavaScript code.
Introduction
At the beginning of this book I will be focusing on a discussion about the
importance and history of design patterns in any programming language. If
you're already sold or are familiar with this history, feel free to the chapter 'What
is a Pattern?' to continue reading.
One of the most important aspects of writing maintainable code is being able to
notice the recurring themes in that code and optimize them. This is an area where
knowledge of design patterns can prove invaluable.
Design patterns can be traced back to the early work of a civil engineer named
Christopher Alexander. He would often write publications about his experience in
solving design issues and how they related to buildings and towns. One day, it
occurred to Alexander that when used time and time again, certain design
constructs lead to a desired optimal effect.
In collaboration with Sarah Ishikawra and Murray Silverstein, Alexander
produced a pattern language that would help empower anyone wishing to design
and build at any scale,. This was published back in 1977 in a paper titled 'A
Pattern Language'.
One of the first and arguably most iconic formal works published on design
patterns in software engineering was a book in 1995 called 'Design Patterns:
Elements Of Reusable Object-Oriented Software'. This was written by Erich
Gamma, Richard Helm, Ralph Johnson and John Vlissides - a group that became
known as the Gang of Four (or GoF for short).
What is a Pattern?
'Pattern'-ity Testing, Proto-Patterns & The Rule Of Three
The Structure Of A Design Pattern
Writing Design Patterns
Anti-Patterns
Categories Of Design Pattern
Design Patterns in jQuery
o Lazy Initialization
o Composite Pattern
o Wrapper Pattern
o Facade Pattern
o Observer Pattern
o Iterator Pattern
o Strategy Pattern
o Proxy Pattern
o Builder Pattern
o Prototype Patern
o Flyweight Pattern
Design Patterns in JavaScript
o Creational Pattern
o Constructor Pattern
o Singleton Pattern
o Module Pattern
o Revealing Module Pattern
o Prototype Pattern
o DRY Pattern
o Facade Pattern
o Factory Pattern
o Decorator Pattern
Conclusions
References
What is a Pattern?
A pattern is a reusable solution that can be applied to commonly occurring
problems in software design - in our particular case, in writing JavaScript
applications. Another way of looking at patterns are as templates for how you
solve problems - ones which can be used in quite a few different situations.
To consider how useful a pattern may be, let us consider that if you were to write
a script where you said ‘for each item, sound an alert’, if sounding an alert was
complex in nature, it would always result in more maintainable code doing the
above over saying ‘do this for item 1’, ‘do this for item 2’, ‘do the same again for
item 3’, i.e. If the code performing the bulk of the work exists in fewer places it
becomes significantly easier to maintain.
You may ask why it’s important to understand patterns and be familiar with
them. Design patterns have three main benefits.
Patterns are not an exact solution. It’s important that we remember the role of a
pattern is merely to provide us with a solution scheme. Patterns don’t solve all
design problems nor do they replace good software designers, however, they do
support them. Next we’ll take a look at some of the other advantages patterns can
offer us.
Looking back upon the work by Alexander once more, he claims that a pattern
should both be a process and a ‘thing’. This definition is obtuse on purpose as he
follows by saying that the process should create the ‘thing’. This is a reason why
patterns generally focus on addressing a visually identifiable structure i.e you
should be able to visually depict (or draw) a picture representing the structure
that putting the pattern into practice results in.
In studying design patterns, you may come across the term ‘proto-pattern’ quite
frequently. What is this? Well, a pattern that has not yet been known to pass the
‘pattern’-ity tests is usually referred to as a proto-pattern. Proto-patterns may
result from the work of someone that has established a particular solution is
worthy of sharing with the community, but may not have yet had the opportunity
to have been vetted heavily due to it’s very young age.
Alternatively, the individual(s) sharing the pattern may not have the time or
interest of going through the ‘pattern’-ity process and might release a short
description of their proto-pattern instead. Brief descriptions of this type of
pattern are known as patlets.
The work involved in fully documenting a qualified pattern can be quite daunting.
Looking back at some of the earliest work in the field of design patterns, a pattern
may be considered ‘good’ if it does the following:
You wouldn’t be blamed for thinking that a proto-pattern that doesn’t meet the
guidelines for a complete pattern isn’t worth investigating, but this is far from the
truth. Many proto-patterns are actually quite good. I’m not saying that all proto-
patterns are worth looking at, but there are quite a few useful ones in the wild
that could assist you with future projects. Use best judgment with the above list
in mind and you’ll be fine in your selection process.
One of the additional requirements for a pattern to be valid is that they display
some recurring phenomenon. This is often something that can be qualified in at
least three key areas, referred to as the rule of three. To show recurrence using
this rule, one must demonstrate:
I find that a lot of the information available out there about the structure of a
good pattern can be condensed down to something more easily digestible. With
this in mind, lets now take a look at a summary of the component elements for a
design pattern below.
Design patterns are quite a powerful approach to getting all of the developers in
an organization or team on the same page when creating or maintaining
solutions. If you or your company ever consider working on your own pattern,
remember that although they may have a heavy initial cost in the planning and
write-up phases, the value returned from that investment can be quite worth it.
Always research thoroughly before working on new patterns however, as you may
find it more beneficial to use or build on top of existing proven patterns than
starting afresh.
Writing Design Patterns
Although this book is aimed at those new to design patterns, a fundamental
understanding of how a design pattern is written can offer you a number of useful
advantages. For starters, you can gain a deeper appreciation for the reason
behind a pattern being needed but can also learn how to tell if a pattern (or
proto-pattern) is up to scratch when reviewing it for your own needs.
Writing good patterns is a challenging task. Patterns not only need to provide a
substantial quantity of reference material for end-users (such as the items found
in the structure section above), but they also need to be able to almost tell a
‘story’ that describes the experience they are trying to convey. If you’ve already
read the previous section on ‘what’ a pattern is, you may think that this in itself
should help you identify patterns when you see them in the wild. This is actually
quite the opposite - you can’t always tell if a piece of code you’re inspecting
follows a pattern.
When looking at a body of code that you think may be using a pattern, you might
write down some of the aspects of the code that you believe falls under a
particular existing pattern, but it may not be a one at all. In many cases of
pattern-analysis you’ll find that you’re just looking at code that follows good
principles and design practices that could happen to overlap with the rules for a
pattern by accident. Remember - solutions in which neither interactions nor
defined rules appear are not patterns.
If you’re interested in venturing down the path of writing your own design
patterns I recommend learning from others who have already been through the
process and done it well. Spend time absorbing the information from a number of
different design pattern descriptions and books and take in what’s meaningful to
you - this will help you accomplish the goals you’ve got of designing the pattern
you want to achieve. You’ll probably also want to examine the structure and
semantics of existing patterns - this can be begun by examining the interactions
and context of the patterns you are interested in so you can identify the principles
that assist in organizing those patterns together in useful configurations.
If you would like to try your hand at writing a design pattern (even if just for the
learning experience of going through the process), the tips I have for doing so
would be as follows:
Bare in mind practicability: Ensure that your pattern describes proven
solutions to recurring problems rather than just speculative solutions which
haven’t been qualified.
Ensure that you draw upon best practices: The design decisions you make
should be based on principles you derive from an understanding of best practices.
Your design patterns should be transparent to the user: Design patterns
should be entirely transparent to any type of user-experience. They are primarily
there to serve the developers using them and should not force changes to
behaviour in the user-experience that would not be incurred without the use of a
pattern.
Remember that originality is not key in pattern design: When writing a
pattern, do you not need to be the original discoverer of the solutions being
documented nor do you have to worry about your design overlapping with minor
pieces of other patterns. If your design is strong enough to have broad useful
applicability, it has a chance of being recognized as a proper pattern
Know the differences between patterns and design: A design pattern
generally draws from proven best practice and serves as a model for a designer to
create a solution. The role of the pattern is to give designers guidance to make
the best design choices so they can cater to the needs of their users.
Your pattern needs to have a strong set of examples: A good pattern
description needs to be followed by an equally strong set of examples
demonstrating the successful application of your pattern. To show broad usage,
examples that exhibit good design principles are ideal.
Anti-Patterns
If we consider that a pattern represents a best practice, an anti-pattern represents
a lesson that has been learned. The term anti-patterns was coined in 1995 by
Andrew Koenig in the November C++ Report that year. It was inspired by the
Gang of Four's book Design Patterns, that developed the concept of design
patterns in the software field. In Koenig’s report, there are two notions of anti-
patterns that are presented. Anti-Patterns:
“These notes are about the process of design; the process of inventing physical
things which display a new physical order, organization, form, in response to
function.…every design problem begins with an effort to achieve fitness between
two entities: the form in question and its context. The form is the solution to the
problem; the context defines the problem”.
The bigger challenges happen after an application has hit production and is ready
to go into maintenance mode. A developer working on such a system who hasn’t
worked on the application before may introduce a bad design into the project by
accident. If said bad practices are created as anti-patterns, they allow developers
a means to recognize these in advance so that they can avoid common mistakes
that can occur - this is parallel to the way in which design patterns provide us
with a way to recognize common techniques that are useful.
Design patterns can be broken down into a number of different categories. In this
section we’ll review three of these categories and briefly mention a few examples
of the patterns that fall into these categories before exploring specific ones in
more detail.
Creational Design Patterns
Creational design patterns focus on handling object creation mechanisms where
objects are created in a manner suitable for the situation you are working in. The
basic approach to object creation might otherwise lead to added complexity in a
project whilst creational patterns aim to solve this problem by controlling the
creation of such objects.
Some of the patterns that fall under this category are: Factory, Abstract,
Prototype, Singleton and Builder.
Patterns that fall under this category include: Decorator, Facade, Composite,
Adapter and Bridge
I recommending using this table as reference, but do remember that there are a
number of additional patterns that are not mentioned on this table but will be
discussed later in the book. That said, it's a great starting point for learning.
Creational Based on the concept of creating an object.
Class
This makes an instance of several derived classes based on
Factory Method
interfaced data or events.
Object
Creates an instance of several families of classes without
Abstract Factory
detailing concrete classes.
Separates object construction from its representation,
Builder
always creates the same type of object.
Prototype A fully initialized instance used for copying or cloning.
A class with only a single instance with global access
Singleton
points.
Note that there is no ‘ideal’ pattern to use from this selection as developers often
use best judgment when deciding on the pattern, which is the best ‘fit’ for their
needs.
Creational Pattern
Constructor Pattern
Singleton Pattern
Module Pattern
Revealing Module Pattern
Prototype Pattern
DRY Pattern
Facade Pattern
Factory Pattern
Decorator Pattern
A lot of the time, you won’t have a reason to approach this in another way. You
just define your class and instantiate it later on when you need it. There are
however situations where this is neither an advantage nor a desired feature.
You’re also able to define custom constructors that define properties and
methods for your own types of objects.
Let’s look at a constructor for a car.
function Car(model, year, miles){
this.model = model;
this.year = year;
this.miles = miles;
this.whatCar = function(){
console.log(this.model);
};
}
The singleton doesn’t provide a way for code that doesn’t know about a previous
reference to the singleton to easily retrieve it - it is not the object or class that’s
returned by a singleton, it’s a structure.
Think of how closured variables aren’t actually closures - the function scope that
provides the closure is the closure.
So, where is the singleton pattern useful?. Well, it’s quite useful when exactly one
object is needed to coordinate patterns across the system. Here’s an example of
the singleton pattern being used:
var SingletonTester = (function(){
The parameters that you decide to use for this class are actually the parameters
for the constructor. Both the local variables and functions defined inside your
class become private members. The return method for your class (ie. still a
function) returns an object that contains your public methods and variables.
A piece of trivia is that the module pattern was originally formally defined by
Douglas Crockford (famous for his book 'JavaScript: The Good Parts, and more),
although it is likely that variations of this pattern were used long before this.
Another piece of trviai is that if you've ever played with Yahoo's YUI library, some
of it's features may appear quite familiar and the reason for this is that the
module pattern was a strong influence for YUI when creating their components.
So, you've seen why the singleton pattern can be useful, but why is the module
pattern a good choice?.
For starters, it's a lot cleaner for developers coming from an object-oriented
background than the idea of true encapsulation, at least from a JavaScript
perspective. Secondly, it supports private data - so, in the module pattern, public
parts of your code are able to touch the private parts, however the outside world
is unable to touch the class's private parts (no laughing!. oh, and thanks to David
Engfer for the joke).
The disadvantages of the module pattern is that as you access both public and
private members differently, when you wish to change visibility, you actually have
to make changes to each place the member was used.
You also can't access private members in methods that are added to the object at
a later point. That said, in many cases the module pattern is still quite useful and
when used correctly, certainly has the potential to improve the structure of your
application.
var someModule = (function(){
//private attributes
var privateVar = 5;
//private methods
var privateMethod = function(){
return 'Private Test';
};
return {
//public attributes
publicVar : 10,
//public methods
publicMethod : function(){
return ' Followed By Public Test ';
},
someModule.getData();
Once again, you’re probably wondering what the benefits of this approach are.
The RMP allows the syntax of your script to be fairly consistent - it also makes it
very clear at the end which of your functions and variables may be accessed
publicly, something that is quite useful. In addition, you are also able to reveal
private functions with more specific names if you wish.
An example of how to use the revealing module pattern can be found below:
/*
The idea here is that you have private methods
which you want to expose as public methods.
function updatePerson(){
name = 'John Smith Updated';
}
function setPerson () {
name = 'John Smith Set';
}
function getPerson () {
return name;
}
return{
set: setPerson,
get: getPerson
}
}();
// Sample usage:
myRevealingModule.get();
The Prototype Pattern
The prototype pattern is based on the concept of prototypal inheritance where we
create objects which act as prototypes for other objects. The prototype object
itself is effectively used a blueprint for each object the constructor creates. If the
prototype of the constructor function used contains a property called 'name' for
example (as per the code sample below), then each object created by that same
constructor will also have this same property.
Looking at the definitions for the prototype pattern in existing literature non-
specific to JavaScript, you *may* find references to concepts outside the scope of
the language such as classes. The reality is that prototypal inheritance avoids
using classes altogether. There isn't a 'definition' object nor a core object in
theory. We're simply creating copies of existing functional objects.
One of the core benefits of using the prototype pattern is that we're working with
the strengths JavaScript has to offer natively rather than attempting to imitate
features of other languages (something a few design pattern implementations
do).
Not only is this an easy way to implement inheritance, but this also comes with a
performance boost as well. When defining a function in an object, they're all
created by reference (so all child objects point to the same function) instead of
creating their own individual copies.
Repetitive code writing generally reduces productivity and leaves you open to
having to re-write code you’ve already written similar times before, thus leaving
you with less time to add in new functionality.
DRY (don’t repeat yourself) was created to simplify this - it’s based on the idea
that each part of your code should ideally only have one representation of each
piece of knowledge in it that applies to your system.
The key concept to take away here is that if you have code that performs a specific
task, you shouldn’t write that code multiple times through your applications or
scripts.
When DRY is applied successfully, the modification of any element in the system
doesn’t change other logically-unrelated elements. Elements in your code that are
logically related change uniformly and are thus kept in sync.
As other patterns covered display aspects of DRY-ness with JavaScript, let's take
a look at how to write DRY code using jQuery. Note that where jQuery is used,
you can easily substitute selections using vanilla JavaScript because jQuery is just
JavaScript at an abstracted level.
Non-DRY
if (this.checked)
{
$('#input_carModel').val(activeSettings.carModel);
$('#input_carYear').val(activeSettings.carYear);
$('#input_carMiles').val(activeSettings.carMiles);
$('#carTint').val(activeSettings.carTint);
} else {
$('#input_carModel').val('');
$('#input_carYear').val('');
$('#input_carMiles').val('');
$('#input_carTint).val('');
}
});
DRY
$('.someCheckbox').click(function(){
var checked = this.checked;
/*
What are we repeating?
1. input_ precedes each field name
2. accessing the same array for settings
3. repeating value resets
We do this by creating a common method that can be used in one’s code which
does the task of checking for the existence of features so that it can provide a safe
and cross-browser compatible solution.
if(el.addEventListener){
el.addEventListener(ev,fn, false);
}else if(el.attachEvent){
el.attachEvent('on'+ev, fn);
} else{
el['on' + ev] = fn;
}
};
The Factory Pattern
Similar to other creational patterns, the Factory Pattern deals with the problem
of creating objects (which we can think of as ‘factory products’) without the need
to specify the exact class of object being created.
This can come in quite useful, in particular if the creation process involved is
quite complex. eg. if it strongly depends on the settings in configuration files.
You can often find factory methods in frameworks where the code for a library
may need to create objects of particular types which may be subclassed by scripts
using the frameworks.
In our example, let’s take the code used in the original Constructor pattern
example and see what this would look like were we to optimize it using the
Factory Pattern:
What is the main benefit of using a decorator pattern? Well, if we examine our
first definition, I mentioned that decorators are an alternative to subclassing.
When a script is being run, subclassing adds behaviour that affects all the
instances of the original class, whilst decorating does not.
It instead can add new behaviour for individual objects, which can be of benefit
depending on the application in question.
Let’s take a look at some code that implements the decorator pattern:
function Memory(macbook){
this.cost = function(){
return macbook.cost() + 75;
};
}
function BlurayDrive(macbook){
this.cost = function(){
return macbook.cost() + 300;
};
}
function Insurance(macbook){
this.cost = function(){
return macbook.cost() + 250;
};
}
// Sample usage
var myMacbook = new Insurance(new BlurayDrive(new
Memory(new Macbook())));
console.log( myMacbook.cost() );
Design Patterns in jQuery
Now that we've taken a look at vanilla-JavaScript implementations of popular
design patterns, let's switch gears and find out what of these design patterns
might look like when implemented using jQuery. jQuery (as you may know) is
currently the most popular JavaScript library and provides a layer of 'sugar' on
top of regular JavaScript with a syntax that can be easier to understand at a
glance.
Before we dive into this section, it's important to remember that many vanilla-
JavaScript design patterns can be intermixed with jQuery when used correctly
because jQuery is still essentially JavaScript itself.
Lazy Initialization
Lazy Initialization is a design pattern where you employ a tactic of delaying
any expensive processes (eg. the creation of objects) until the first instance they
are needed. An example of this is the .ready() function in jQuery that only
executes a function once the DOM has fully loaded.
$(document).ready(function(){
$('#content').fadeIn();
});
$.get();
$.post();
$.getJSON();
$.getScript();
Iterators encapsulate the internal structure of how that particular iteration occurs
- in the case of jQuery’s .each() iterator, you are actually able to use the
underlying code behind .each() to iterate through a collection, without needing to
see or understand the code working behind the scenes that's providing this
capability.
$.each(function(){});
$('.items').each(function(){});
You could say that the biggest benefit this pattern offers is that it allows
algorithms to vary independent of the clients that utilize them. An example of this
is where jQuery’s toggle() allows you to bind two or more handlers to the
matched elements, to be executed on alternate clicks.
$('#container').toggle(function(){}, function(){});
$.proxy(function(){}, obj);
Below is an example of how jQuery utilizes this pattern to allow an element which
you may wish to append to the document body to be constructed using a string
definition.
$.fn.plugin = function(){}
$('#container').plugin();
$.fn.plugin = function(userConfig){
userConfig = $.extend({
content: 'Hello user!'
}, userConfig);
return this.html(useConfig.content);
});
A side-note here is that prototypal inheritance in JavaScript uses differential
inheritance to only define objects once in a prototype chain until they are
overridden. This makes it easier to save memory.
Conclusions
That’s it for this introduction to the world of design patterns in JavaScript &
jQuery– I hope you’ve found it useful. The contents of this book are in no way an
extensive look at the field of patterns, but should give you enough information to
get started using the patterns covered in your day-to-day projects.
Design patterns make it easier to reuse successful designs and architectures. It’s
important for every developer to be aware of design patterns but it’s also essential
to know how and when to use them. Implementing the right patterns intelligently
can be worth the effort but the opposite is also true. A badly implementing
pattern can yield little benefit to a project.
Also bare in mind that it’s not the number of patterns you implement that’s
important but how you choose to implement them. For example, don’t choose a
pattern just for the sake of using ‘one’ but rather try understanding the pros and
cons of what particular patterns have to offer and make a judgement based on it’s
fitness for your application.
If I’ve encouraged your interest in this area further and you would like to learn
more about design patterns, there are a number of excellent titles on this area
available for generic software development but also those that cover specific
languages.
Thanks for reading Essential JavaScript & jQuery Design Patterns. For more
free learning material on JavaScript, jQuery and User-Interface Design, check out
my official site over at http://addyosmani.com for my latest educational
resources.
References
1. Design Principles and Design Patterns - Robert C
Martinhttp://www.objectmentor.com/resources/articles/Principles_and_Patter
ns.pdf
2. Ralph Johnson - Special Issue of ACM On Patterns and Pattern Languages -
http://www.cs.wustl.edu/~schmidt/CACM-editorial.html
3. Hillside Engineering Design Patterns Library - http://hillside.net/patterns/
4. Pro JavaScript Design Patterns - Ross Harmes and Dustin Diaz
http://jsdesignpatterns.com/
5. Design Pattern Definitions - http://en.wikipedia.org/wiki/Design_Patterns
6. Patterns and Software Terminology
http://www.cmcrossroads.com/bradapp/docs/patterns-intro.html
7. Reap the benefits of Design Patterns - Jeff Juday
http://articles.techrepublic.com.com/5100-10878_11-5173591.html
8. JavaScript Design Patterns - Subramanyan Guhan
http://www.slideshare.net/rmsguhan/javascript-design-patterns
9. What Are Design Patterns and Do I Need Them? - James Moaoriello
http://www.developer.com/design/article.php/1474561
10. Software Design Patterns - Alex Barnett
http://alexbarnett.net/blog/archive/2007/07/20/software-design-patterns.aspx
11. Evaluating Software Design Patterns - Gunni Rode http://www.rode.dk/thesis/
12. SourceMaking Design Patterns http://sourcemaking.com/design_patterns
13. The Singleton - Prototyp.ical
http://prototyp.ical.ly/index.php/2007/03/01/javascript-design-patterns-1-the-
singleton/
14. JavaScript Patterns - Stoyan Stevanov -
http://www.slideshare.net/stoyan/javascript-patterns
15. Stack Overflow - Design Pattern Implementations in JavaScript (discussion)
http://stackoverflow.com/questions/24642/what-are-some-examples-of-design-
pattern-implementations-using-javascript
16. The Elements of a Design Pattern - Jared Spool
http://www.uie.com/articles/elements_of_a_design_pattern/
17. Stack Overflow - Examples of Practical JS Design Patterns (discussion)
http://stackoverflow.com/questions/3722820/examples-of-practical-javascript-
object-oriented-design-patterns
18. Design Patterns in JavaScript Part 1 - Nicholas Zakkas
http://www.webreference.com/programming/javascript/ncz/column5/
19. Stack Overflow - Design Patterns in jQuery
http://stackoverflow.com/questions/3631039/design-patterns-used-in-the-
jquery-library
20. Classifying Design Patterns By AntiClue - Elyse Neilson
http://www.anticlue.net/archives/000198.htm
21. Design Patterns, Pattern Languages and Frameworks - Douglas Schmidt
http://www.cs.wustl.edu/~schmidt/patterns.html
22. Show Love To The Module Pattern - Christian Heilmann http://www.wait-till-
i.com/2007/07/24/show-love-to-the-module-pattern/
23. JavaScript Design Patterns - Mike G.
http://www.lovemikeg.com/2010/09/29/javascript-design-patterns/
24. Software Designs Made Simple - Anoop Mashudanan
http://www.scribd.com/doc/16352479/Software-Design-Patterns-Made-Simple
25. JavaScript Design Patterns - Klaus Komenda
http://www.klauskomenda.com/code/javascript-programming-patterns/
26. Design Patterns Explained - http://c2.com/cgi/wiki?DesignPatterns
27. Working with GoF’s Design Patterns In JavaScript
http://aspalliance.com/1782_Working_with_GoFs_Design_Patterns_in_JavaS
cript_Programming.all
28. Design Patterns by Gamma, Helm supplement
http://exciton.cs.rice.edu/javaresources/DesignPatterns/
Essential JavaScript & jQuery Design Patterns. Copyright Addy Osmani 2010.