Addy Osmani is a Senior Staff Engineering Manager working on Google Chrome. He leads up teams focused on making the web fast and low-friction to build on for developers. Addy has authored a number of books and has spoken at conferences around the world.
Å·±¦ÓéÀÖ.com has a that states that reviews must be about the book, and not about the author. Now, I happen to agree with the spirit of this guideline, but I also feel like that guideline gets a little fuzzy when you’re looking at non-fiction, and especially fuzzy when you’re talking about technical books. I mention this because this provides the appropriate frame of reference for what I’m about to say next: that I was disappointed in Addy Osmani’s Learning JavaScript Design Patterns (O'Reilly, 2012), but that most of my disappointment is because I hold him in high esteem, and as such was expecting so much more from this book. [1] What was I expecting? A deep dive into how can be (and are) applied to JavaScript development. But (and here’s where it gets weird) that’s also exactly what Osmani delivers. So why the disappointment? Because it felt like a compilation or round-up of blog posts on the subject.
In other words: it is a Greatest Hits album–if someone made a Greatest Hits album of blog posts from JavaScript pedants.
On the surface, many of my quibbles with the book seem like nit-picks:
� The first eight chapters seem like they could have been rolled into one; � The section on namespacing patterns seems like it should have been its own stand-alone chapter, and not “jammed in� with the jQuery plug-in design patterns; and � what is with the single-page final “Conclusions� chapter? [2]
But I feel like these things are important. The structure of the book is important. How the information flows from one chapter to the next is important. The top-level chapter titles that you’re scanning in the table of contents are important. As I finished the book, it seemed to me that there was important information in there that was otherwise buried or obfuscated. If you didn’t know to look at sections within the chapter (or else weren’t patient enough to do so) then you might never know that there was a comprehensive discussion of namespacing patterns embedded within the discussion of jQuery plugin design; nor would you know that the “JavaScript Design Patterns� chapter was a (nearly) exhaustive walking tour through the Gang of Four’s patterns as they align with JavaScript-based software development.
I don’t place all of the blame on Addy Osmani for this, though. As I pondered my disappointment, I realized that his editors probably phoned it in with this one. Though some effort would be required to restructure the book, I think there was some easy guidance they could have given about restructuring the book to make it easier to bring out the highlights; but they just didn’t bother. Even if we give them the benefit of the doubt and assume that they meant for it to be published this way, I maintain that they half-assed the editing; [3] for example:
� The heading levels did not always have a clear correspondence with the level of importance for that section; [4] � The 2d object property notation on page 210 which (as it’s written) is clearly invalid JavaScript; � The multiple (multiple!) instances where (unescaped!) double-quotes are used within double-quotes–and how the syntax highlighting in the text even gives this away as a syntax error; and � Speaking of syntax highlighting, how it’s applied inconsistently throughout the electronic version of the book.
Like I said: they really phoned in the editing.
Now, there is a highlight reel here. There is plenty of useful content within the book–and this comes back to my original statement about feeling let down because of how much respect I have for Osmani. As anyone who reads Osmani’s blog (or his guest posts around the web, or his screencasts�) knows–he has a terrific pedagocial streak, and it’s clear that he enjoys helping people learn, and that he’s particularly adept at helping them learn to be better front-end developers. Throughout the first eight chapters, [5] he does a fantastic job of defining what constitutes a pattern, of explaining why we (as front-end developers) should care about and study design patterns, and of what makes something an anti-pattern. Chapter Nine (the “walking tour� of the Gang of Four patterns) has the right balance between discussing the theoretical details behind a given pattern, and an illustration of its practical application. The most critical follow-up to Chapter Nine is found in Chapter Twelve, which essentially takes jQuery and uses it as a case study for those design patterns in action. Lastly, you can think of Osmani as providing a curator’s role with this book; there are many places in the text where he is citing work from others as either illustrating a particular facet of a design pattern, or else as building on it in some important way. [6]
And/but I also think that for getting the maximum value out of this book, you need to be a part of the right audience. In the preface, Osmani writes that the target audience is “professional developers wishing to improve their knowledge of design patterns and how they can be applied to the JavaScript programming language� (pp. ix). He assumes that you have a good intermediate knowledge of JavaScript to begin with (“You do know what a closure is, right?�) but not necessarily that you are “advanced�, and not necessarily that you have made a formal study of computer science. [7] That being said, his statement that the book is targeted at “professional developers� seems a bit broad to me. A non-trivial proportion of the text has jQuery as its focus, [8] which leads me to conclude that the book is targeted more at front-end developers that (for better or worse) lean heavily on the jQuery for their heavy-lifting.
Putting all of this together, I believe that if I were forced to choose, I would recommend over Osmani’s JavaScript Design Patterns. Don’t get me wrong: if your bookshelf as room for both, then it’s worth it to explore both; each covers subject matter than the other does not, but in the places where they overlap, I find that Stefanov’s book rings a little bit more rigorous. Osmani’s book seems a bit more current with respect to citing specific technologies, but that also suggests to me that it will feel out-dated just a little more quickly.
(Disclosure: I received an electronic copy of this book from the publisher in exchange for writing this review.)
----
[1] Perhaps that’s the price of success? That the people that admire you wind up feeling let down when you deliver something that’s� Only average? Not mind-blowing? There’s a part of me that thinks I’m being unfair or too harsh, but at the same time� Sometimes you need to hold folks to high standards?
[2] Granted: I’ve dinged other books for not having a “concluding� chapter, and for otherwise ending abruptly while wrapping up some other subject ( book comes immediately to mind)�clearly I would rather have a weak “concluding� chapter than no concluding chapter at all. So I’m kind of being a hypocrite here. Kind of.
[3] Mostly the technical editing; but it seems like the copy-editing suffered a bit as well. (My heart sank a little bit when I saw the second ‘k� in Nicholas Zakas' name in the reference section.)
[4] If we assume that a chapter’s title is an H1 heading, major sections are an H2, and so on down the list, then I would submit that there are numerous examples throughout the text where we have H2-level headings that seem like they should be H3 or below. E.g., how “Pseudoclassical Decorators� and “Decorators with jQuery� are both H2 level headings, but feel like H3 level sub-sections to “The Decorator Pattern� section; e.g., the H2 level “Namespacing Patterns� section that (in my mind) really should mark a whole new chapter in its own right.
[5] Again: those first eight chapters really ought to have been formed up like Voltron into one.
[6] And here is where recipients of the ebook version may be better off. I’m not sure how the links and references appear in the print book, but the ebook has clickable links to blog posts and other websites. Which is great. Thumbs up to that.
[7] Which, thank goodness for that, since so many of us front-end developers are self-taught “liberal arts majors drafted into web developer service during the dotcom boom�. (Tip o' the hat to Eric Miraglia for that quote from his foreword to .)
[8] I have mixed feelings about this part of my critique. On the one hand, jQuery is a prevalent (pervasive?) library used by a huge number of front-end developers. And for better or worse, that library is synonymous with JavaScript as a whole to many developers. That being said, it seems disingenuous to call the book “JavaScript Design Patterns� when you’re dedicating two of your most lengthy and substantial chapters to that library. Perhaps the “Get Out of Jail Free� card here is that (1a) one of those chapters is really more of a case study and (1b) that so many folks are familiar with the library makes it a good case study because it’s familiar and also (2) if that helps these lessons reach and resonate with your target audience, then that’s probably a good thing.
Good book that taught me how to recognize some of the patterns I've been recognizing in other peoples' code. I thought the second half of the book got unnecessarily bogged down in third party library examples for Backbone, Knockout, JQuery and others. Felt like this was out of scope for the book and would have preferred to see more vanilla javascript pattern implementations. Notably, I really skimmed past many of the jQuery plugin examples because while good to know they were there, they weren't immediately useful to me.
As I write this in 2020 after first reading this book years ago, I still pop back in every now and then since the concepts are sound. Considering how radically different front end development is these days, it's great to see where so many patterns we take for granted came from, or just to get to know the history of what we're doing. Things look a lot different with the declarative frameworks of today but understanding modular code and how to leverage the language itself is still essential to being productive.
Reads like a collection of slightly out of date blogs. Good information on some the more commonly known patterns, but that same information has been presented in a much better way elsewhere. Better off sticking with the original GoF or for a more modern take: /book/show/1...
For when you're ready to level up from beginner to intermediate. I started it ages ago and couldn't quite get it, then retried recently and it was so useful.
I saw another review that said the book read like a slightly out of date collection of blogs. By the time you get to the last 50% of the book it is definitely the case. The book is largely out of date with modern Javascript, but is still useful.
There's good "chapter" where they go through a number of the design patterns and show how you would implement them in Javascript. That is then followed up with the last several chapters where you get a paragraph of text and then a wall of code. This wall of code would show you how something would work in jQuery or some other "framework" on top of Javascript.
The sections on jQuery, Backbone, and Knockout aren't as essential as they used to be, but still provide useful context. It's important to remember how much of a wild west the JS ecosystem was, and how far we've come, but also how simple JS remains and how much you can do without requiring massive frameworks or libraries. These patterns are useful and used today, and will continue to outlive the framework du jour
First of all I didn't read it cover to cover but at the same time I probably would have if I won't have find parts of it outdated. It's quite library dependent in sense that you'd learn more about how to use different libraries to implement a pattern. The web version of the book is free and I think the author has done a lot for the JS community as this book has been around for long, so I salute the author for his work.
Whether you've read the staple JavaScript: The Good Parts or you're just getting started with this language, the design patterns explained in this book will both save you time catching unseen errors in your code architecture and teach you best practices for using JavaScript. If this is your only JavaScript book, you're still in very good hands as a beginner or intermediate developer.
Didn't find it that useful and decided to find another source to learn about design patterns. A lot of stuff are outdated, a lot explained in jquery and other technologies that are not that familiar nowadays in my opinion.
I read the new edition. It's updated in parts and bizarrely antiquated in other parts. On the whole I don't recommend it - read the website patterns.dev, also by the author, instead. It has much of the same content, plus some updates and with the old stuff removed.
I read the second edition, but I can't find it on Å·±¦ÓéÀÖ. I'm really disappointed with the book, especially with the examples. Code samples are usually simple, and it is more like a collection of blog posts than a programming book.
Unfortunately most of the book was not new and re-used from the previous version. Many code samples also used code from other books about JS Design Patterns. So one could suddenly see a method used for creating an Interface, wonder where that implementation is, well a link to a gist is then provided because it's from another book.
I liked most of the content besides those hiccups along the way. A nice overview was added for React, but of course only scratching the surface. So it's as Addy said in the end, it's a good intro and you will learn something, if you want to go deeper into the topic. There are other books and sites to help you out.
I would recommend it, since you will get a quick idea of new frameworks and patterns. It would be good to update some parts already, since React has changed again and it's API as well, so I would assume, although not mentioned explicitly that the version used here is before 18. (It was only mentioned in Hooks that they are available from 16.8, so we can be sure the book is later than that version.)
Book didn't go well with me: it seems like the author was discovering the patterns through the first link he found on Google, not through the hard-won first-hand experience. It was written at the strange time where JavaScript started to go somewhere, but was not as big as it is now, so admittedly there was no such widely shared experience as it was, for example, with other languages (Java, C, etc.).
Differences between patterns described very vaguely, and I didn't gain any particular insights about nor design patterns, nor JavaScript. Sometimes I got a feeling like the author didn't fully understand the pattern or at leas could not convey his knowledge in words to transmit this knowledge.
The writing style looked to me as more of a blog writing style than 'serious book', but that would not be a problem if the content was good as per above.
I'm disappointed in this book - all the explanations are fuzzy, examples don't show the gist of the patterns... If you are looking for a good book on the subject I would recommend Stoyan's book /book/show/9.... It does the job and explains patterns that exist in the javascript world.
And if you want to take a deep dive into GoF patterns - just have a look at /book/show/5.... Despite the fact that all the examples are written in java - this book is the best guide to GoF patterns.
P.S. What I haven't got at all is why author dedicated half of the book to jQuery design patterns, dojo and backbone.js... It looks like he ran out of ideas and decided to stuff the book with this just to satisfy a publisher...
Learning JavaScript Design Patterns, 2nd Edition is an absolute game-changer for JavaScript developers. The book's well-structured approach, clear explanations, and practical examples make it a must-have resource. It goes beyond theory and emphasizes practical application, providing real-world scenarios where design patterns can be effectively used. The code examples are meticulously crafted, following best practices and promoting good coding habits. Covering a wide range of design patterns, the book offers a comprehensive understanding of creational, structural, and behavioral patterns. With its relevance to current JavaScript trends and its ability to elevate programming skills, this second edition surpasses its predecessor.
Maybe I should have read the book description and summary better, but I skipped the later half of the book almost entirely.
The first half is all about Patterns. And you do learn it. Each pattern is well explained, with code examples, and Addy starts with the simple patterns and build upon it, getting more complex, but you can follow along.
Then, suddenly, the book shifts from explaining each pattern to describing how several libraries, specially jQuery and Backbone, implement (in detail) some patterns. And you learn some patterns now for plugins of jQuery, in even more details.
Since I was not interested in how jQuery plugins do something, I just enjoyed half of the book.
I read the first half only. It reads like a rough draft. I don't know what the first edition was like. It kind of feels like they took the first edition and halfway revised it to update it. Reads like it was rushed out. In some cases it seems like the description of a pattern is included less to give a programmer a useful tool, and more to check a box, like, "okay that well known pattern is in the book now." The result is that the explanation of each pattern feels incomplete and seems much more difficult to understand than it could be. Code snippets sometimes appear abruptly without enough explanation before or after. Some sections seem to use many words without making the point explicit.
- Good review of commonly used patterns with examples - Tries to cover a bunch of commonly used libraries/frameworks such as knockout, jquery, and backbone. - The narrative is very technical, sometimes I would get tired of the book and then pick it up back again, just because I know the knowledge inside is important and I should master it (perhaps I like books that guide you through and teach while building something, those are less boring)