lundi 1 février 2016

Function that acts like a decorator, but uses mutation instead of wrapping?

A decorator adds additional functionality to an object by "wrapping" around the original value.

Is there a name for an object or function that ingests a pre-constructed object and adds additional functionality to it via mutation?.

Example:

function mutatesObjects(target) {
  target.additionalFunctionality = "I've been mutated!";
}

This is similar to a contrcutor or factory except that it is adding functionality to an object that was already created.

Is there a name for this pattern?

Aucun commentaire:

Enregistrer un commentaire