[Pharo-users] Traits for class methods?
cyril.ferlicot at gmail.com
Wed Feb 13 08:54:21 EST 2019
On Wed, Feb 13, 2019 at 2:40 PM Hilaire <hilaire at 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?
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
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.»
> Dr. Geo
More information about the Pharo-users