3 ms·
> But is there a fundamental benefit of composition over inheritance in ever circumstance? I don't have much time now, but a fundamental difference is that inh
by shock 8y ago
> But is there a fundamental benefit of composition over inheritance in ever circumstance?
I don't have much time now, but a fundamental difference is that inheritance happens at compile time (it's rare/nonexistent that you can change the class hierarchy at runtime) while composition happens at runtime – this means that with composition one can change the behavior of a class at runtime by inserting in a field a different implementation of an interface, for example.