Tuesday, October 2, 2012

Review: "Learning JavaScript Design Patterns" by Addy Osmani


Learning JavaScript Design Patterns
Since I started re-learning JavaScript after an absence of 7 or 8 years, I've found all sorts of great free resources online and purchased a ton of great books (JavaScript: The Good Parts, Maintainable JavaScript, Secrets of the JavaScript Ninjas (MEAP), JavaScript Web Applications, and Professional JavaScriptfor Web Developers); I've read two of them so far.  This new book, Learning JavaScript Patterns by Addy Osmani, was released both freely via Creative Commons on the internet and through O’Reilly, and I decided to add it to my stack.  (Full disclosure: I got the ebook for free from O’Reilly).

I found much of the book helpful, but it suffers from being uneven and unfocused.  There are 14 chapters in the book but 80% of the content is in chapters 9 through 13.  The first 8 chapters and introductory, repetitive, and short.  It would have been better to have a single 10 or 15 page introduction than eight 2 page chapters.  Even beginners could safely skip to chapter 9. 

Unlike other Pattern books that are systematically organized, it is hard to understand the structure of the book.  In the introductory chapters a table is given of the patterns described in the rest of the book, but it doesn't include page references.  Sometimes patterns are mentioned before they are actually described. The GOF patterns described rely, as you would expect, on Design Patterns by Gamma et al., but I don’t think the author described well how (or if) these patterns fit into JavaScript other than showing an implementation.  The chapter on User Interface patterns was good, heavily relies on Martin Fowler’s work, but seemed out of place where it was located.  The jQuery Plug-in Design Patterns chapter, was excellent and new, at least, to me.

The best chapter in the book is chapter 12, “Design Patterns in jQuery.”  It describes patterns by showing them in use in jQuery, and providing commentary on the actual source.  If the entire book had been organized like chapter 12, this would be a five star review.

One nice thing about the book is the many references included.  Almost everything was backed up by at least one, sometimes several, blog posts or articles by experts. 

The eBook originally had many errors in its diagrams, but O’Reilly has updated it recently, and most of the problems seem to be fixed.  I was disappointed with the kindle version which I read on my iPod; I had to switch to the PDF at times to understand the book.  Usually O’Reilly creates excellently formatted eBooks, so that was surprising.

There was a lot of good in this book, especially in the later chapters, but I would have a hard time recommending it for purchase, when the content is available online in a searchable form for free.

Product Information: