JavaScript Patterns

Web applications these days, am I right? With all their user experience and fancy A/B tests. It’s all thanks to JavaScript, or, more correctly, browsers and developers alike finally biting the bullet, putting a paper bag over the language’s proverbial head, and getting some good use out of it.

Analogies aside, JavaScript is not so great, but the experts have found ways to reclaim their software engineering integrity. Buried under metric tonnes of “Top 43 jQuery Plugins and Extensions for the Colorblind”, you might actually find such a beacon of knowledge. One of those beacons is a new book, JavaScript Patterns, by Stoyan Stefanov.

My copy is already getting dog ears.

A little bit of personal background, a couple years back I was starting to feel pretty comfortable with jQuery and even started writing my own extensions (not for the colorblind). I was also reading a new book, JavaScript: The Good Parts, by Douglas Crockford. Even though I strongly recommend it, JS: TGP raised more issues than it clarified. Sure, don’t use this and that part of JavaScript, but is that all there is, just a minefield of features, waiting to trip me up? Furthermore, many of those antipatterns he described really only became problematic in larger projects. Shouldn’t I be more concerned about confidently architecting and building those larger projects? I was unable to convince myself that JavaScript was a safe platform on which a very small team could build a stable product. (I even have an ActionScript 3 book from those days.)

Now, end of 2010, enter JavaScript Patterns. It aims to provide insight and best practices for teams who want to create a JavaScript product that won’t be hell to develop and maintain. And for the most part, it’s successful. Stoyan is an engineer at Yahoo, working on YUI, and just off the top of my head, he’s also written Object-Oriented JavaScript and a chapter in High-Performance JavaScript.

Pros

  1. Really does deliver on holistic, well-justified JavaScript programming techniques that embrace the language.
  2. Assumes the appropriate amount of JavaScript and CS knowledge, not too much, not too little.
  3. Focuses mainly on JavaScript, not too much on the specifics of external libraries like jQuery. Libraries these days are big and numerous; a dedicated book for those would probably be more helpful. This one is library-agnostic and might even stay applicable longer.
  4. Adequate treatment of server-side JavaScript. By which I mean, almost none. Similar to the library issue above, server-side JavaScript is still JavaScript. It’s also very volatile and most of the server-side-specific stuff is not unique to JavaScript.

Cons

  1. Could give a little more focus to external libraries. I know I just got done saying that it was a good thing that it didn’t, but face it, almost everyone uses some external library. I think there’s a lot of general advice that one could give to allow developers to extract more from their library of choice while loosening any coupling that may occur along the way.
  2. Lulls a bit in Chapter 6, Code Reuse.
  3. The quote on the back of the book is probably the weakest bit.

    “Stoyan has written the go-to guide for JavaScript developers working on large-scale web applications.”

    Don’t get me wrong, it’s definitely my go-to guide (outside of good old Google), but the quote is from Ryan Grove, YUI Engineer. No offense to Ryan, but if you write a sweet book the publisher should try to hook you up with a quote from someone a little more prestigious than your own coworker.

And that’s all I have to say about that. For the time being, 8.5/10, highly recommended. It’s not very long and it really sets some precedents on which to build. For more study, I recommend you check out YUI Theater and follow some blogs. Ajaxian is great and all, but the real in-depth stuff comes out of projects and project contributors, check out Kangax’s blog (of Prototype fame) and Tim Caswell’s How to Node.

About these ads

One response to “JavaScript Patterns

  1. REQUESTED COMMENT:

    not particularly interested in javascript, as the whole web stack is a mound of fail. however, please do post more frequently, mahmoud.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s