Full-featured, testable OOP



Troop features

  • multiple inheritance with traits
  • makes use of ES5 property attributes
    • pseudo-privates are non-enumerable
    • constants are actually read-only
  • testing mode for applying mock methods
  • postponed, on-demand property definitions
  • delegation of instantiation with surrogates
  • support for instance memoization

Troop is distinguished from other OOP-related libs such as MooTools or Backbone by

  • not littering your classes and instances with its own meta-properties
  • non-declarative API leads to better IDE integration
  • offering simpler unit testing with built-in mocks to speed up TDD process


var MyClass = troop.Base.extend()
        _secret: "ufo" // static private property
        hello: "world" // static public property
        pi: 3.14 // static public constant
        init: function (who) {
                hello: who

var myInstance = MyClass.create("all");

myInstance in console

Check out these jsFiddles for more examples: