2013/7/19 Igor Stasenko <[email protected]> > I just stumbled upon this: > > Announcer subclass: #TxEditor > .... > > This is just plain wrong, as wrong as: > > Shampoo subclass: #Shower > > because every time you treat inheritance as something else as > _specialization_ you doing it wrong. > Inheritance is not about importing needed functionality, it should be > about specialization and only about it: >
Completely agree! If you inherit only because of reuse functionality, use traits instead :-) - a superclass provides generic functionality, while subclasses > providing more and more specialized forms of it. > > Because if we don't follow that, then it is really hard to see and > follow a structure in design.. it is just random. > > And here's why: > > so since shower uses shampoo, as we concluded, then why not including > it via inheritance: > > Shampoo subclass: #Shower > > but then, Shower also uses Soap, so maybe it should be like that: > > Soap subclass: #Shower > > so, which superclass you prefer most? And how do you pick/prioritize > which element should be a superclass of Shower? > > To solve this dilemma, i think we will need multiple inheritance: > > (Shampoo, Soap) subclass: #Shower > > but thankfully, we don't have it in classic smalltalk model :) > > So, then maybe it should be something like that: > > Object subclass: #Shower > instanceVariableNames: 'soap shampoo' > ... > > Anyways, despite the obvious abuses, i'd like to ask community, in > what cases , you think (ab)using inheritance in a way > like above is justified? > Because maybe it is i, who doing it wrong? > > > -- > Best regards, > Igor Stasenko. > >
