Jump to ratings and reviews
Rate this book

Mastering JavaScript Design Patterns

Rate this book
Enhance your JavaScript code with this essential collection of design patterns. Discover an extensive range of techniques and strategies to successfully tackle complex JavaScript development problems and put them into practice by following detailed examples that demonstrate each design pattern at its most effective. Dive deeper into JavaScript and master these powerful design patterns for an innovative and cutting-edge approach to JavaScript that meets the demands of modern web development.

Explore how design patterns can help you improve your JavaScript code and get to grips with creational, structural behavioural patterns, as you discover how to put them to work in different scenarios. Then look deeper at patterns used in functional programming, as well as model view patterns, and patterns to build web applications. You will also find patterns to improve the testability of your code using mock objects, mocking frameworks and monkey patching along with some advanced patterns including dependency injection and live postprocessing.

Taking a complete and journey through the most valuable design patterns, and providing clear guidance on how to effectively use them in JavaScript, this JavaScript book gives you access to one of the best ways to learn JavaScript and use it to meet the demands of web development today.

Discover and use tried and tested design patterns for a more effective approach to JavaScript
Learn simple strategies for improving your code organization
Get to grips with creational, behavioural and structural design patterns
Rethink and revitalize your code with the use of functional patterns
Harness the power of design patterns for a range of development tasks from building an application to code testing
Explore advanced JavaScript design patterns including dependency injection

290 pages, Paperback

First published November 21, 2014

16 people are currently reading
82 people want to read

About the author

Simon Timms

7 books

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
11 (33%)
4 stars
19 (57%)
3 stars
1 (3%)
2 stars
1 (3%)
1 star
1 (3%)
Displaying 1 - 10 of 10 reviews
1 review2 followers
December 31, 2014
Coming from a background of coding in C++, Java and Ruby, the object oriented programming took time to wrap my head around when coding in Javascript. I've had an opportunity to create a large application using AngularJS and several smaller applications over a couple of years. Each left new curiosities in the process - How can I create a better interface? How can I abstract certain areas of my code and expose only a few? How can I protect the object attributes better? On my journey to satisfy these curiosities, Mastering JavaScript Design Patterns has entered recently as a great teacher.

It starts with introducing the history of Javascript. Further, it leads into the basics of how code is organized in javascript while comparing with traditional OOPs concepts of classes, modules and inheritance. It also introduces ES6 early in the book and the new syntax sugar available in it that makes the code more readable.

It then descends into the design patterns grouped traditionally as GOF creational, structural, behavioral patterns. I've had several Aha! moments while reading these. The javascript duck typing and the absence of traditional classes and interfaces makes the implementations quite different from what you would see in a traditional OOP language like C++ and Java. The author makes a great effort in presenting it well and entertaining by introducing examples related to Game of Thrones. For those who have watched it, can relate to it, for those who haven't, Spoilers Alert! No. Not really... :)

It further gets more interesting in further chapters on topics that apply to modern Javascript applications and play to the special powers of Javascript. The topics include functional programming and how the patterns used in the modern frameworks like Angular work. I haven't read them all yet but took a sneak peek and am looking forward to be reading them.

Reading the book feels like attending a computer science lecture from a good professor. The author tries to make remarks in parentheses like "aren't you glad I chose to use this example" or when he highlights his witty puns. The author makes references to other programming language and presents different angles to a problem and the philosophical side to it which makes it a great read and gives a lasting impression.

Highly recommended to all javascript developers to better their software craftsmanship.
Profile Image for Damir Arh.
17 reviews2 followers
January 12, 2015
I was really glad to see that the book is actually not just about design patterns. It does a great job at introducing JavaScript as a language from all aspects. From a brief history of this controversial language it quickly dives into its most important specifics which tend to elude the developers coming from other languages such as Java or C#. This serves as a great way to make the book easier to follow even for those with less experience in JavaScript.

The title makes it clear that the majority of the book is focusing on software design patterns. The first part is dedicated to the well known patterns from the classical "Gang of Four" book, but instead of just rehashing its contents, the author takes a different approach and reevaluates the meaning of the same design patterns in a dynamic language like JavaScript in contrast to the object oriented languages from the original book.

The reading gets even more interesting in the second part, which moves on to the more recent design patterns, grouped into different fields of interest: functional programming, automated testing, user interface, web and messaging. Each and every design pattern is introduced in a broader context, with a discussion of its advantages and drawbacks. Most of them are even accompanied by interesting examples from the lively world of A Song of Ice and Fire. At the very end a couple of words are dedicated to the broader topic of dependency injection, aspect-oriented programming and macros, each one of them deserving a book of its own.

With brief mentions interspersed throughout the book, the author also managed to give an overview of the libraries and tools in the current JavaScript ecosystem, without really favoring any of them. A special place among them is reserved toTypeScript and Traceur, 2 languages which extend the current JavaScript with features from its future version ECMAScript 6, but can be compiled back to valid JavaScript of today.

I can recommend the book not only to JavaScript developers, but also to others who want to refresh or expand their knowledge of design patterns. Learning some JavaScript in the process is just an additional benefit.
1 review1 follower
February 7, 2015
This is a very good intermediate level text on JavaScript design patterns (it is not aimed at people who have not used JavaScript before).

The book has a logical flow to it, starting with the history of JavaScript, looking at JS objects and inheritance before looking at design patterns - starting with the GoF patterns before moving on to JS specific patterns (note that anti-patterns are not covered).

I liked the authors writing style, it's concise and to the point but written in a light conversational style. He describes each pattern, what it does and where/if it is appropriate to use it. There are code examples for most of the patterns, for the main part they are in plain JS although there are some examples which use jQuery and pseudocode. Interestingly in the final chapter of the book the author says that all the code examples shown were originally done in TypeScript and compiled to JS.

There are mentions of ECMAscript 6 and 7 features, with a few examples showing the new methods. There is also coverage of some tools and libraries that are currently in use or up and coming.

The section on testing won't satisfy test specialists because it only covers unit testing with some integration and UI testing coverage. It is sufficient information to get going with though and there are many excellent books/websites available to help you with TDD or further test strategies/types.

There are a few minor typos, e.g. In relation to the publication of the GoF book the author says " ... now been a decade" but the typos are minor and do not detract from the book overall.

So, why didn't I give the book 5 stars then, the reason is the examples, the ones used relate to a (medieval style) fictional land or gods/religions, I would prefer examples that use real life web development scenarios e.g. E commerce

Disclosure - I was given a free copy of the book in exchange for an honest review.
30 reviews4 followers
January 8, 2015
I reviewed a Dart book before saying that I started to be interested in Dart
because of architectural issues when developing complex libraries
with JavaScript. I do consider switching my client-side web projects to other languages
targetting JavaScript as implementation language.
However if you really need to keep JavaScript as the development
language and you have no idea how to improve the situation with
complex JavaScript library, this book is for you.
It describes a lot of concepts familiar to big/infrastructure programming
developers but less familiar to developers doing only small apps.
It then explain good ways to manage Javascript code in these cases,
which is insanely difficult but doable in some ways if you have enough experience.
This book seem to help a lot acquiring this experience by explaining why
a specific pattern or rule of thumb will help in the context of JavaScript.
Basically, I wish I had read such a book before starting to build complex
apps in JavaScript.
1 review1 follower
January 29, 2015
This is an excellent book for anyone who wishes to consolidate their knowledge and experience of patterns in the JavaScript arena.
The first part is an interesting summary of each pattern, with examples of how they can be applied. Anyone familiar with Game of Thrones will find them especially descriptive.
The second part of the book is worth its weight in gold however, making this a must read for anyone who wishes to make the transition from JavaScript novice. In particular, it ensures the transfer of knowledge of these principles from either the classroom or other languages to JavaScript. Having a starting point in which to jump in, allows the transition to be smoother and saves the frustration of trial and error.
The simple and concise style with which Simon Timms writes his book allows the reader to clearly grasp the principles without unnecessary clutter.
7 reviews
January 7, 2015
Highly recommended to anyone who approaches the topic for the first time and for those who already knows the design patterns and want to learn how to implement them in javascript.
The book is clear, easy to understand and full of useful examples that aids understanding the concepts.
Profile Image for Julio Biason.
199 reviews28 followers
April 2, 2016
With a book named "Master JavaScript Design Patterns", I was expecting something about some JavaScript common patterns, like subscribing and generating events, proper way of transversing structures and such.

But nope.

The book starts with the classical design patterns from the Gang of Four, which doesn't seem so bad if the book was named "Learning Design Patterns with JavaScript", in a way to make learning the design patterns more streamlined for people who already know JavaScript. But, then again, things fall apart, with the Observer pattern being designed with a list of callbacks in a structured, instead of creating a real event -- something, again, really common in JavaScript.

Not only that, but some stuff seems really off. Like explaining lazy evaluation -- something only ES6 has -- with... lists. Yup, lazy evaluation, for the book, means adding things in a list only when you need to remove things from the list. It would make so much more sense if the author jumped into the ES6 bandwagon for this and explained the "yield" command... but no, he had to write some lazy text.

The fact that all examples are based on Game of Thrones -- with all being based on things that happen in Westeros -- don't make it funny or interesting. Worse, none of the examples are related, so the author just keeps jumping between weird scenarios to explain the "patterns".

Even when you throw the JavaScript away and decide to read it to learn some design patterns, you waste your time. Some designs, mostly the MV*, are hastily described and just superficially analyzed.

It really starts a bit off -- again, if it was "Learning Design Patterns with JavaScript", it would be almost perfect -- and then goes downhill by some lazy writing and wrong assumptions.
1 review12 followers
January 28, 2015
Considering the history of Javascript and the mayhem it has caused over time, it's good to see a book like this. Simon has managed to include the part of the language you should learn about, rather than the unnecessary.

Above being a browser tool, Javascript is a language; with constructs, control flow, a prototype-based approach to structuring systems and a promising class model that will support classical object-oriented techniques better than ever.

Simon tells you a story about a medieval people with different challenges. These will be tackled in a rather whimsy fashion through the many classical and modern patterns that are used in modern software industry.

If you're looking to go beyond the average Javascript developer, this is the book to read. It is written in a simple way while covering complex topics. The narrative is easy to follow. You will definitely improve.
1 review
January 28, 2015
A must-have book for all people involved in JavaScript that want to write elegant and reusable code.

The book has a really practical approach and presents an in-depth walk-through of the classical GOF patterns and the new ones that you may find on the web, all looked from the JavaScript programmer side with useful example.
I've found really interesting the chapter that illustrate the test pattern, written by the author in an indipendent-tool way, bringing the user to apply the know-how to the tools he found comfortable with.

I think that everyone involved in serious JavaScript programming should have the expertise that you may found in this book. The book should be useful also as a good reference handbook for expert programmer.
Displaying 1 - 10 of 10 reviews

Can't find what you're looking for?

Get help and learn more about the design.