DEVURANDOM.ORG, random bits from Deryck Hodge
  • Work
  • Links
  • Blog
  • About

Why I don't love JavaScript's Module Pattern

Came across this a few weeks ago, and though I thought Snook's points were valid, I dismissed this post as wishful thinking -- wishful thinking in that avoiding the module pattern is virtually impossible in JavaScript, especially if you use a library like YUI, which he cites in the post. Really, it's XHR that makes the use of enclosures a near must. Having said that, I just put some code through review on Launchpad that I felt was unnecessarily complex because of the use of enclosures, the "module pattern" as he calls it. I will be refactoring the code in a later branch and will definitely try to limit enclosure use to simplify the code, but still, I'm skeptical I'll get the code as nice as I would like. There's just something about asynchronous code in JavaScript that gets complex quickly, especially when dealing with many XHRs or multiple levels of XHRs.

Post a comment

The writing for this website is Copyright © Deryck Hodge 2003-2011 and is licensed under a Creative Commons License.

Code is subject to the license included with the source.

The opinions expressed here are entirely my own, and not those of my employer.

Website screenshots generously provided by ShrinkTheWeb.

Made with Django.