DCL

An elegant OOP with mixins + AOP for JavaScript.

About

A minimalistic yet complete JavaScript package for node.js and browsers. It implements OOP with mixins + AOP at both “class” and object level.

The goal of dcl is to provide a sound OOP/AOP foundation for projects of all sizes, while promoting the best practices to keep user’s codebase small and DRY.

It is a tool to structure a project as a set of small orthogonal mixins glued together with supercalls, chaining, and advices leading to reducing the overall codebase, and clear path to refactor the resulting project.

It is started by Eugene Lazutkin, and publicly available on GitHub.

Overview

  • Works in node.js and browsers, fully supports AMD.
    • Fully compatible with strict mode.
  • Small codebase.
    • Easy to learn, easy to use.
    • Intentionally small set of orthogonal features.
  • Extensively tested.
  • Liberally licensed.
    • Available under new BSD or AFL v2 – your choice.
    • Free for commercial and non-commercial use.
  • Legally clean code.
    • Developed in the open.
    • All contributions are covered by CLA.

Highlights

  • Targets OOP with mixins technology.
    • Supports a Python-like multiple inheritance (implements the same C3 MRO algorithm).
    • Efficient supercalls — no run-time penalty, ultimate debuggability.
    • Automatic constructor chaining, and you can specify chaining for any method.
  • Full support for AOP (before, around, after returning, and after throwing advices).
    • AOP can be applied at “class” level (statically) or at object level (dynamically).
    • Dynamic advices can be unadvised at any time.
  • Comes with a mini library of useful generic building blocks.

Stress on debuggability

The package was written with debuggability of your code in mind. It comes with a special debug module that verifies created objects, explains mistakes, and helps to keep track of AOP advices.

Because dcl uses direct static calls to super methods, you don’t need to step over unnecessary stubs. In places where stubs are unavoidable (chains or advices) they are small, and intuitive.

Installation

If you plan to use it in your node.js project install it like this:

1
npm install dcl

For your browser-based projects I suggest using volo.js:

1
volo add -amdoff uhop/dcl

You can find more details and instructions for some other package managers in Installation guide.

Happy coding!

Fork me on GitHub