Learning JavaScript Design Patterns
Addy Osmani
(O’Reilly, paperback – Kindle)
New to JavaScript and jQuery or looking to expand your skills? This well-focused how-to guide can help you learn how to recognize and apply reusable design patterns to your coding.
“A pattern is a reusable solution that can be applied to commonly occurring problems in software design—in our case, in writing JavaScript web applications,” Addy Osmani notes in his new book. He is a developer programs engineer on the Chrome team at Google, and he is a frequent contributor to publications such as JavaScript Weekly.
“Another way of looking at patterns is as templates for how we solve problems—ones that can be used in quite a few different situations,” Osmani adds.
In his view, design patterns offer three key benefits for JavaScript and jQuery developers. First, the patterns offer “proven solutions….They provide solid approaches to solving issues in software development using proven techniques….” created and tested by others. Second, design patterns “can be easily reused” and offer “an out-of-the-box solution that can be adapted to suit our own needs.” And, third, “patterns can be expressive…there’s generally a set structure and vocabulary to the solution presented that can help express rather large solutions quite eloquently.”
Osmani also emphasizes that patterns do not provide “exact solutions…the role of a pattern is merely to provide us with a solution scheme.” But a key goal of his book is to convince JavaScript and jQuery developers that “[r]eusing patterns assists in preventing minor issues that can cause major problems in the application development process.”
Learning JavaScript Design Patterns (235 pages) is structured with 14 chapters and an appendix.
- Introduction
- What Is a Pattern?
- “Pattern”-ity Testing, Proto-Patterns, and the Rule of Three
- The Structure of a Design Pattern
- Writing Design Patterns
- Anti-Patterns
- Categories of Design Patterns
- Design Pattern Categorization
- JavaScript Design Patterns
- JavaScript MV* Patterns
- Modern Modular JavaScript Design Patterns
- Design Patterns in jQuery
- jQuery Plug-in Design Patterns
- Conclusions
The appendix, “References,” includes 39 links for additional information related to JavaScript design patterns.
The author offers numerous code samples and graphics to help illustrate his explanations. He provides looks at more than 20 “classical and modern” design patterns in JavaScript. And he explains several choices for writing modular code, including the Module pattern, Asynchronous Module Definition (AMD), and CommonJS.
He also describes design patterns available within the jQuery library and explores “a number of jQuery plug-in patterns that have worked well for other developers in the wild.”
Addy Osmani’s well-written book provides clear guidance to understanding how adapting and using existing design patterns can help software developers work more efficiently and effectively in JavaScript and jQuery.
— Si Dunn