Object factories were competing models (plural) for creating any object. A total replacement for classes and the like, not an augmentation.
Here's one such model:
function createCar(spec) { const {speed} = spec; let position = 0; return Object.freeze({ move() { position += speed; }, get position() { return position; } }); }
It sucked.
> Don’t use this or new in your code
You are going to be mutating the internal state of objects. Using this and new or not.
Object factories were competing models (plural) for creating any object. A total replacement for classes and the like, not an augmentation.
Here's one such model:
And so you'd find this or any other model or multiple competing models in the very same code base.It sucked.
> Don’t use this or new in your code
You are going to be mutating the internal state of objects. Using this and new or not.