4 ms·
Nice. One metaphor that I like to use in OO is that inheritance is best used to "fill in holes." Imagine that an abstract class is a class with holes in it (i
by michaelfeathers 14y ago
Nice.
One metaphor that I like to use in OO is that inheritance is best used to "fill in holes." Imagine that an abstract class is a class with holes in it (i.e., the abstract methods). Subclassing fills in the holes and gives you a complete class. That is really the best use of inheritance. If you override, you have a higher chance of breaking behavior via a Liskov Substitution violation.
- st0p 14y agoYou mean the template pattern as described in GOF? Very nice nice and underused pattern, but sometimes it is better to use some event based system as mentioned in the article and sometimes it is better to just be rude and overwrite a method (very nice metaphore BTW). More "traditional" OO like C++ or Java let the developer choose. The "traditional" way gives you more flexibility and more ways to shoot yourself in your foot.
- MartinCron 14y agoYou mean the template pattern as described in GOF? Very nice nice and underused pattern The template pattern was when I finally "got" design patterns, realizing that they were ways of describing and communicating (some) things that I was already doing.
- helpermethod 14y agoActually I think when Java will finally introduce anonymous functions the Template Pattern will be obsolete. The strategy pattern is IMHO much more flexible and can be used everywhere where the template pattern is used.