JS.Class 1.5 is now out

Hot on the heels of Ojay comes a new release of JS.Class, my Ruby-inspired JavaScript library for class-based OOP. Ojay is itself based on JS.Class, and has influenced the design of some of its new features. There has been one small change to the 1.0 API, and a stack of additional modules added in; it’s not really a 1.1 release or a 2.0 release, hence 1.5.

The one change to the 1.0 API is that _super is now called callSuper. Ojay uses a compression strategy that obfuscates ‘private’ variables (this will be in the next PackR release, as and when Packer 3.1 comes out). You do need to be very careful when doing this, though, so I figured I should make super not look like a private variable just in case.

Now, onto the new stuff. This release adds tons of new features to play with, namely:

  • Implementations of several design patterns in such a way that minimises how much repetitive boilerplate you need to write to use them. (I’m becoming more and more convinced that repetition is one of the largest and most easily removable causes of software bugs.) Patterns include decorator, virtual proxy, observer and command.
  • Versions of Ruby’s Comparable, Enumerable and Observable modules.
  • Linked lists. They’re like arrays, but much better suited to removal, shift operations and reordering.
  • MethodChain, formerly known as ChainCollector. This module on its own is responsible for some of Ojay’s key features.

So, what are you waiting for? Go and download it and tell me what you think.

If you’ve enjoyed this article, you might enjoy my recently published book JavaScript Testing Recipes. It’s full of simple techniques for writing modular, maintainable JavaScript apps in the browser and on the server.