Saturday, April 11, 2015

JavaScript "classes" my way

I group information about an object in to a "unit" object which holds information about the inputs to make the object, the interface of the object created, the functional constructor for the object, and unit testing for the object. My motivation was to build as much documentation and testing about the object in to the code itself. Validation of the inputs and created objects can also be done easily with some helper functions as long as the same convention is followed. More complicated hierarchies can be created easily with this model, without really introducing any new syntax or dealing with prototypes. I'm assuming something like QUnit is used for unit testing.