Mostly, but not always, about developing software.

Tuesday, October 6, 2009

Moving to modular Javascript

Once in a while, you come across a site that has exactly the information you're after, when you need it. Recently I was bashing out some Javascript in my usual function-frenzy, randomly adding various comments like

// TODO: get rid of all these globals
// TODO: make this more modular and nice
// TODO: I know this is bad, but I'll fix it up later

JavaScript Programming Patterns does a terrific job of showing in simple terms some of the approaches to better programming styles for Javascript. I especially like how it discusses moving from the "Old-School Way" (that's me) to my current favourite, "Revealing Modular Pattern". It took me about 15 mins to refactor to this pattern, and I'm already feeling the benefits, particularly in introducing some much needed testing.

Twitter Updates

    follow me on Twitter

    Followers