Review: JavaScript Patterns

This post is more than 2 years old.

In my (seemingly) never-ending quest to improve my JavaScript skills, I recently received a copy of JavaScript Patterns by Stoyan Stefanov. While I feel very comfortable with jQuery and simple Ajax applications, I feel like I'm still missing... something in terms of constructing JavaScript heavy applications, especially those used within Adobe AIR applications. A few months back I reviewed Object-Oriented JavaScript which was also by Stefanov. JavaScript Patterns is an excellent followup and I'd definitely recommend it.

The book begins by discussing some JavaScript basics - just to ensure you have a proper understanding of what is - and what is not - supported in terms of object, inheritance, classes, etc. Issues surrounding variables and the global object are also discussed. Probably the most interesting aspect of the first portion to the book was the discussion on JSLint, a JavaScript code quality tool. Shoot - I didn't even know code quality tools existed for JavaScript before reading this book.

The middle section of the book was a bit difficult for me. Stefanov spends a lot of time talking functions and defining them. He also spends an incredible amount of time discussing object creation patterns. I had a very hard time with this. I get that there isn't "One Right Way" to solve a problem. I preach that all the time in the ColdFusion community. But I found a lot of this discussion to be hard to relate to. It's not that he doesn't provide examples. He does - quite a few. But I had a hard time relating them to practical uses in my own development. I decided to not stress out too much over it and return to the chapter later on. I had the same trouble with the section on inheritance. I just don't see myself needing inheritance yet in my development.

The final two chapters though were really exciting. Chapter 7 is on "Design Patterns." I feel like I've just recently gotten a hang on them in general - both in the ColdFusion and ActionScript world. Seeing them discussed in JavaScript and "getting it" was a great feeling. Chapter 8, "DOM and Browser Patterns", was also great. Some of the material I already knew but Stefanov covered them in a fresh way that helped really bring home the concepts.

I'd definitely recommend picking the book up (and as a reminder, if you click via the pretty picture above I get a kickback) as well as the previous one I reviewed. Both together would be a great way to lift your JavaScript development up to a new level. While I still think I've got a lot to learn, I'm feeling more comfortable in terms of approaching larger, more complex JavaScript based applications now.

p.s. One final note - and it's soapbox time so feel free to stop reading. I'm no Microsoft hater. Heck, I've dumped Apple and switched over to Windows 7. But it is truly a sad thing that every JavaScript book has to spend time talking about how IE has failed in some regard or another. I mean think of it - you have a browser that basically fracked over development as we know it. Ok, maybe that's a bit dramatic, but it seems like someone at Microsoft should be ashamed of themselves. I hear IE9 is "better" (meh, I'm a Chrome guy now), but it's like Microsoft has 'stained' the history of the browser and that's pretty sad.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Drew Wells posted on 12/15/2010 at 12:13 AM

You should try out JavaScript Design Patterns now. The whole book is about Chapter 7 and they go to the extreme providing thorough examples of all the patterns. It's a more abstract book so you won't see so much IE talk in it.

I try not to slam IE, since most of the problems are DOM related and not JS related (besides the non-conforming API, frame quirks and timing mechanisms). It would be nice to get a serious debugger in IE. In the same sense, FireFox has no debugger either as you will see how far behind Firebug the FF 4 beta debugger is.

Comment 2 by Raymond Camden posted on 12/15/2010 at 12:15 AM
Comment 3 by Matt posted on 12/15/2010 at 10:54 PM

You might be interested to read up on the history of JavaScript and JScript and why the divergence between the two languages occurred the way it did. I was surprised when I learned that it was not really Microsoft's fault that IE had a vastly different version of ECMAScript running than Netscape did but it was in fact Netscape's. In the early days JavaScript's copyright held by Netscape was enforced so Microsoft did their best to backwards engineer the tech, which resulted in JScript, now because JScript is a legacy technology they have to do their best to ensure backward compatibility.

I first heard this in a lecture by Douglas Crockford, author of JavaScript the Good Parts, and probably the most notable figure in the JavaScript community. You can view his lectures over at YUI theater for free.

Comment 4 by Roland Collins posted on 12/15/2010 at 11:20 PM

I actually think IE8 is pretty solid in terms of JS (and not even that bad at CSS). In IE8, I don't think I've ever had to work around a browser-specific issue in standards mode. If my JS works in FF, it just works in IE8 as well. Now that doesn't mean I don't hate me some IE6 and IE7...we've got a ton of workarounds in our codebase for those monsters.

@Drew - I actually find the debugger in IE8 to be pretty good. It's not *quite* FireBug, but it's close enough for most normal development situations IMO. What are your beefs with it?