Preface |
|
ix | |
|
|
1 | (2) |
|
|
3 | (4) |
|
We Already Use Patterns Every Day |
|
|
4 | (3) |
|
3 "Pattern"-ity Testing, Proto-Patterns, and the Rule of Three |
|
|
7 | (2) |
|
4 The Structure of a Design Pattern |
|
|
9 | (2) |
|
5 Writing Design Patterns |
|
|
11 | (2) |
|
|
13 | (2) |
|
7 Categories of Design Patterns |
|
|
15 | (2) |
|
Creational Design Patterns |
|
|
15 | (1) |
|
Structural Design Patterns |
|
|
16 | (1) |
|
Behavioral Design Patterns |
|
|
16 | (1) |
|
8 Design Pattern Categorization |
|
|
17 | (4) |
|
|
17 | (4) |
|
9 JavaScript Design Patterns |
|
|
21 | (88) |
|
|
22 | (4) |
|
|
22 | (2) |
|
|
24 | (1) |
|
Constructors with Prototypes |
|
|
25 | (1) |
|
|
26 | (11) |
|
|
26 | (1) |
|
|
27 | (5) |
|
Module Pattern Variations |
|
|
32 | (5) |
|
The Revealing Module Pattern |
|
|
37 | (2) |
|
|
38 | (1) |
|
|
38 | (1) |
|
|
39 | (3) |
|
|
42 | (17) |
|
Differences Between the Observer and Publish/Subscribe Pattern |
|
|
46 | (2) |
|
|
48 | (1) |
|
|
49 | (1) |
|
Publish/Subscribe Implementations |
|
|
49 | (10) |
|
|
59 | (10) |
|
|
60 | (1) |
|
|
61 | (5) |
|
|
66 | (2) |
|
Advantages and Disadvantages |
|
|
68 | (1) |
|
|
68 | (1) |
|
|
68 | (1) |
|
|
69 | (3) |
|
|
72 | (2) |
|
|
74 | (3) |
|
|
76 | (1) |
|
|
77 | (4) |
|
When to Use the Factory Pattern |
|
|
80 | (1) |
|
When Not to Use the Factory Pattern |
|
|
80 | (1) |
|
|
80 | (1) |
|
|
81 | (1) |
|
|
81 | (2) |
|
|
83 | (3) |
|
Advantages and Disadvantages |
|
|
86 | (1) |
|
|
86 | (4) |
|
Pseudoclassical Decorators |
|
|
90 | (4) |
|
|
90 | (1) |
|
|
91 | (3) |
|
|
94 | (2) |
|
Advantages and Disadvantages |
|
|
96 | (1) |
|
|
96 | (13) |
|
|
97 | (1) |
|
Flyweights and Sharing Data |
|
|
97 | (1) |
|
Implementing Classical Flyweights |
|
|
98 | (3) |
|
Converting Code to Use the Flyweight Pattern |
|
|
101 | (2) |
|
|
103 | (1) |
|
Managing the Extrinsic States |
|
|
104 | (1) |
|
The Flyweight Pattern and the DOM |
|
|
105 | (4) |
|
10 JavaScript MV* Patterns |
|
|
109 | (30) |
|
|
109 | (1) |
|
|
109 | (1) |
|
MVC for JavaScript Developers |
|
|
110 | (8) |
|
|
111 | (2) |
|
|
113 | (2) |
|
|
115 | (1) |
|
Controllers in Another Library (Spine.js) Versus Backbone.js |
|
|
116 | (2) |
|
|
118 | (1) |
|
Smalltalk-80 MVC in JavaScript |
|
|
118 | (1) |
|
|
119 | (1) |
|
|
119 | (1) |
|
|
119 | (4) |
|
Models, Views, and Presenters |
|
|
120 | (1) |
|
|
121 | (1) |
|
MVC, MVP, and Backbone.js |
|
|
121 | (2) |
|
|
123 | (7) |
|
|
124 | (1) |
|
|
125 | (1) |
|
|
125 | (3) |
|
|
128 | (2) |
|
Recap: The View and the ViewModel |
|
|
130 | (1) |
|
Recap: The ViewModel and the Model |
|
|
130 | (1) |
|
|
130 | (1) |
|
|
130 | (1) |
|
|
130 | (1) |
|
MVVM with Looser Data Bindings |
|
|
131 | (4) |
|
MVC Versus MVP Versus MVVM |
|
|
135 | (1) |
|
Backbone.js Versus KnockoutJS |
|
|
136 | (3) |
|
11 Modern Modular JavaScript Design Patterns |
|
|
139 | (26) |
|
|
140 | (1) |
|
|
140 | (10) |
|
Getting Started with Modules |
|
|
141 | (3) |
|
|
144 | (1) |
|
AMD Module Design Patterns (Dojo) |
|
|
145 | (2) |
|
|
147 | (2) |
|
|
149 | (1) |
|
|
150 | (3) |
|
|
150 | (1) |
|
Consuming Multiple Dependencies |
|
|
151 | (1) |
|
Loaders and Frameworks that Support CommonJS |
|
|
151 | (1) |
|
Is CommonJS Suitable for the Browser? |
|
|
152 | (1) |
|
|
152 | (1) |
|
AMD and CommonJS: Competing, but Equally Valid Standards |
|
|
153 | (5) |
|
UMD: AMD and CommonJS-Compatible Modules for Plug-ins |
|
|
153 | (5) |
|
|
158 | (4) |
|
Modules with Imports and Exports |
|
|
159 | (1) |
|
Modules Loaded from Remote Sources |
|
|
160 | (1) |
|
|
160 | (1) |
|
CommonJS-like Modules for the Server |
|
|
160 | (1) |
|
Classes with Constructors, Getters, and Setters |
|
|
161 | (1) |
|
|
162 | (1) |
|
|
162 | (1) |
|
|
162 | (3) |
|
12 Design Patterns in jQuery |
|
|
165 | (14) |
|
|
165 | (1) |
|
|
166 | (2) |
|
|
168 | (2) |
|
|
170 | (3) |
|
|
173 | (1) |
|
|
174 | (2) |
|
|
176 | (1) |
|
|
177 | (2) |
|
13 jQuery Plug-in Design Patterns |
|
|
179 | (44) |
|
|
180 | (1) |
|
A Lightweight Start Pattern |
|
|
181 | (2) |
|
Complete Widget Factory Pattern |
|
|
183 | (2) |
|
Nested Namespacing Plug-in Pattern |
|
|
185 | (2) |
|
Custom Events Plug-in Pattern (with the Widget Factory) |
|
|
187 | (2) |
|
Prototypal Inheritance with the DOM-to-Object Bridge Pattern |
|
|
189 | (2) |
|
jQuery UI Widget Factory Bridge Pattern |
|
|
191 | (2) |
|
jQuery Mobile Widgets with the Widget Factory |
|
|
193 | (3) |
|
RequireJS and the jQuery UI Widget Factory |
|
|
196 | (3) |
|
|
198 | (1) |
|
Globally and Per-Call Overridable Options (Best Options Pattern) |
|
|
199 | (1) |
|
A Highly Configurable and Mutable Plug-in Pattern |
|
|
200 | (3) |
|
What Makes a Good Plug-in Beyond Patterns? |
|
|
203 | (1) |
|
|
203 | (1) |
|
|
203 | (1) |
|
|
203 | (1) |
|
|
203 | (1) |
|
|
204 | (1) |
|
|
204 | (1) |
|
Likelihood of maintenance |
|
|
204 | (1) |
|
|
204 | (1) |
|
|
205 | (1) |
|
|
205 | (10) |
|
|
205 | (1) |
|
|
206 | (1) |
|
|
206 | (4) |
|
|
210 | (1) |
|
Immediately Invoked Function Expressions (IIFE)s |
|
|
211 | (2) |
|
|
213 | (2) |
|
Advanced Namespacing Patterns |
|
|
215 | (8) |
|
Automating Nested Namespacing |
|
|
215 | (2) |
|
Dependency Declaration Pattern |
|
|
217 | (1) |
|
|
218 | (3) |
|
|
221 | (2) |
|
|
223 | (2) |
Appendix: References |
|
225 | (4) |
Index |
|
229 | |