He and I have been through this before, and I can guarantee you he won’t agree.
Jeff M

Hmm….I appreciate the explanation. However, I understand Eric’s position about composition more than I do your position about stampit being the same as class inheritance, sorry to say.

> If you use inheritance according to his rules, then he calls that object composition.

That’s not what he said. He said:

> All object composition is a form of inheritance. The question is, are we inheriting the class, or are we inheriting component parts to form a larger whole?

There is an important point in that. “are we inheriting component parts to form a larger whole”.

The goal with composition is to create has-a relationships between the objects. Class hierarchies can only create is-a relationships. That is the evil of “extends” and the coupling it causes with child/parent relationships or even worse, deeper hierarchies.

With a properly composed object built with more than two other objects (like with stampit), there is no inheritance coupling between the component objects used. This is impossible to do with classes in JavaScript, as extended classes always cause objects to be connected over delegation chains (JavaScript’s prototypal inheritance). This is also why class is a bad or rather an improperly included addition to JavaScript. It may offer some simplicity to building objects, however it also makes it simple to create delegation chain hierarchies, which should be shunned, just like class hierarchies should be shunned in classical OOP languages.

In your examples earlier, you only considered one class and then extended from it. It is obvious no matter what one does, the “extending” of one object in JavaScript will alway use prototypal inheritance (delegation), so Eric’s stampit and classes must work with those same rules. However, that doesn’t disprove stampit’s ability to compose a number of objects to one whole and still avoid prototypal delegation. It’s most definitely **not** the same as class inheritance.

Try creating has-a relationships with multiple classes by extending them. It simply won’t work. With stampit, you can combine multiple objects (for code reuse) and avoid delegation chaining/ inheritance between them. That is the pragmatism and best practice being offered with stampit.