Re:The impoliteness of overriding methods
by st0p on Wednesday December 19, 2012 @04:33PM
(#4944980)
You 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.
Re:The impoliteness of overriding methods
by MartinCron on Wednesday December 19, 2012 @06:52PM
(#4945522)
You 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.
Re:The impoliteness of overriding methods
by helpermethod on Thursday December 20, 2012 @08:18AM
(#4947545)
Actually 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.
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.