easejs

Classical Object-Oriented Framework

Classical Object-OrientedJavaScript Framework

GNU
ease.js is a Classical Object-Oriented framework for JavaScript, intended to
eliminate boilerplate code and “ease” the transition into
JavaScript from other Object-Oriented languages. Features include:

GNU ease.js is a framework, not a compiler. It may be used wherever JavaScript
may be used, and supports all major browsers; ease.js also provides support
for older, pre-ES5 environments by gracefully degrading features (such as
visibility support) while remaining functionally consistent.

Classes can be extended to create subtypes. Like C++, methods are
not virtual by default. In Java terminology, all methods are
final by default. Multiple inheritance, like Java, is unsupported (see
Interfaces).

Trait support was introduced in celebration of becoming a GNU
project. It is currently under development and has not yet been
finalized, but has been included in each GNU ease.js release since v0.2.0,
and is stable.

In the above example, the database connection remains encapsulated within
DatabaseRecord. Subtypes are able to query and escape strings and
external callers are able to retrieve a name for a given id. Attempting to
access a private or protected member externally will result in an error.
Attempting to access a private member from within a subtype will result in an
error.

Alternatively, a more concise style may be used, which is more natural to
users of JavaScript's native prototype model:

Static members are bound to the class itself, rather than a particular
instance. Constants are immutable static members (unlike languages like PHP,
they may use any access modifier). In order to support both
pre- and
post-ECMAScript 5 environments, the syntax requires use of a static
accessor method—$().

Error subtyping (creating your own error types) in ECMAScript is
notoriously crude, and getting it to work intuitively is even
harder. ease.js transparently handles all necessarily boilerplate when
extending Error or its subtypes.