I've been thinking a lot lately about client-side development (as is hopefully evident by the type of posts I've been making). I feel like I've finally gotten comfortable with JavaScript, but am looking for ways to bring my skill set to the next level. In general, I'm looking for ways to better organize my code. I know that design patterns can help me with that goal. So I was pretty excited to get "Learning JavaScript Design Patterns" by Addy Osmani. My expectation was that this book would give me a good overview of the various types of patterns I could apply to my client-side work. Unfortunately, I don't know if the book reaches that goal. Let me explain why.
The book does a good job of introducing the concept of patterns in general, as well as explaining why classical patterns that you may have applied from a traditional object-oriented environment may not apply as well to JavaScript. These are important concepts, but I feel like the book focuses a bit too much on them. There is an even an entire chapter dedicated to writing patterns before the reader is introduced to any actual patterns. It isn't a big chapter, but I felt like so much time was spent on theory in the beginning that people who are not traditional comp-sci folks (like many web developers) may be a bit put off. Right after the chapter on writing patterns is a discussion on anti-patterns. Again, I think this is an important concept, but it just continues to delay the introduction of proper JavaScript patterns.
When the book finally does get down to business (chapter 9), the examples are both good and bad. They are good in that they demonstrate the concept at hand, but bad in that there are very few practical examples. For example, a basket module (somewhat related to a shopping cart) in the abstract isn't terribly helpful. I was really hoping to see a full, if short, web application that demonstrated the pattern in use. I know "real" applications can be difficult, but I feel like too few of the code samples actually bring the concept home for the reader. As another example, there is an entire section on jQuery Plugin design patterns. To me, that seems like such a limited audience it just adds to the 'noise' of the book.
I think this is the biggest fault of the book. If you're experienced in traditional programming, you can take the book and use it well. If you're the traditional web developer (who typically learned in bits and spurts as they had to) then it will be very difficult to take practical benefit from this book.
This is something I find in many cases throughout the web community. I feel like there's a great deal of intro material, a great deal of very high end abstract material, and very little in terms of intermediate-level discussion. It feels painful to go from Beginner to Intermediate versus Intermediate to Advanced. I'm not sure if others feel that way, but thats how it seems to me.
I think I can recommend this book if you've got some experience with patterns already, but not if you're coming from a non-CompSci (or server-side) background. I've got a great deal of respect for Addy and would recommend his blog and any presentation he gives.
For folks curious about what type of material I think does do a good job of having practical examples, I'd strongly recommend the new series by Elijah Manor: The Angry Birds of JavaScript This is exactly what I'd like to see more of!