On Wed, Feb 13, 2019 at 2:40 PM Hilaire <hilaire@drgeo.eu> wrote:
I am wondering. Does it not make responsabilities less clear, shareed in class hierarchy and traits hierarchy, now both in term of behavior but also state?
Hi, In general I do not choose between inheritance and composition based on what the language allows. When we had stateless traits, I created subclasses even if I was not using any state, because it made sense. I'm not a big fan of limiting the language on composition because the choice between composition and inheritance should be conceptual and not technical. I read in an article this way to choose between inheritance and composition: «Inheritance should only be used when: - Both classes are in the same logical domain - The subclass is a proper subtype of the superclass - The superclassâs implementation is necessary or appropriate for the subclass - The enhancements made by the subclass are primarily additive.»
Hilaire
-- Dr. Geo http://drgeo.eu
-- Cyril Ferlicot https://ferlicot.fr