When Subclasses Are Ready To Die

I don’t like to inherit implementation (create subclasses). When refactoring class hierarchies, I often pull behavior up into superclasses, then out into collaborators. Over time, I might find myself left with subclasses that only differ by overriding methods to return different constant values. Smalltalkers are used to this, but I never felt entirely comfortable with it. (No, I can’t explain that.) I often end up here because I’ve moved all the significant behavior variations out into collaborating objects, leaving behind tiny differences. The resulting subclasses amount to nothing more than slightly-varied configurations of a common type. We might end up with a situation with the same shape as this stupid, trivial example.


This is a companion discussion topic for the original entry at http://blog.thecodewhisperer.com/permalink/when-subclasses-are-ready-to-die

Yout link to “Can Programming Be Liberated from the von Neumann Style? A Functional Style and Its Algebra of Programs” doesn't seem to work.

Fixed. Thanks.