Testing

Closure Exposure

These days people are becoming more aware that you can write real object oriented code in Javascript. Even though the language doesn’t support classes with private members directly, you can achieve the same thing quite easily using closures.

Static classes and unit testing

If you unit test your code (and I hope you do), you’ll quickly discover that you need to mock out parts of the system. This is much easier if you design with testability in mind from the start of the project. In particular, as you’ll see, you need to be very careful about where you use static classes.