adequately good

decent programming advice

written by ben cherry



all articles filed under module pattern

Writing Testable JavaScript

The engineering culture at Twitter requires tests. Lots of tests. I haven't had formal experience with JavaScript testing before Twitter, so I've been learning a lot as I go. In particular, a number of patterns I used to use, write about, and encourage have turned out to be bad for writing testable code. So I thought it would be worthwhile to share a few of the ...

Debugging Closures and Modules

The most common complaint with using closures to keep private variables in JavaScript is that it makes debugging harder. This complaint definitely holds water, and the loss of easy debugging and inspection using the Module Pattern is a serious concern. This is where one of JavaScript's non-standard but well-supported features comes in: the debugger statement. In this article, I'll introduce this statement, and show how I ...

JavaScript Module Pattern: In-Depth

The module pattern is a common JavaScript coding pattern. It's generally well understood, but there are a number of advanced uses that have not gotten a lot of attention. In this article, I'll review the basics and cover some truly remarkable advanced topics, including one which I think is original.

The Basics

We'll start out with a simple overview of the module pattern, which has ...