I’m genuinely trying to figure out where you draw the line between inheritance and what you call object composition, so if you don’t mind, I’d like to show some examples and have you label them as either inheritance or composition.
First up is similar to the fragile base example from a couple posts ago. One type incorporates the structure and behavior of another, plus it overrides a method. Here it is in your stamps, in ES6 classes, in Python, and in C++. In a past post, you already called this classical inheritance, even when it’s done using your stamps. I assume that’s still your position?
Next up, nearly the same example but without the override. One type incorporates the structure and behavior of another, and that’s it. Here it is in your stamps, in ES6 classes, in Python, and in C++. It seems like this fits your criteria for being what you call object composition, yet it also seems that anyone looking at the ES6, Python, or C++ code would say this is unambiguously classes and classical inheritance.
And finally, nearly the same example but now one type incorporates the structure and behavior of *two* other types. This is an almost verbatim example from your stamp docs where C is composed of an A and a B. Here it is in your stamps, and here in Python and in C++ which both natively support multiple inheritance, and in ES6 classes with a helper to support multiple inheritance. Since this example is verbatim from your stamp docs, I presume you consider this object composition? Yet, as before, it seems that anyone looking at the Python and C++ code would say this is unambiguously classes and classical inheritance (albeit multiple inheritance). And the ES6 code also looks and works like classical multiple inheritance.
To boil it down, what’s the difference for you between:
class C(A, B):
and
c = stampit.compose(a, b);
They both look and work the same. They both provide the same benefits and, if not used carefully, the same pitfalls. Yet one is unambiguously classical multiple inheritance and the other is what you call object composition.