I sometimes end up with a class hierarchy, where I have an abstract base class with some common functionalities and several implementation classes that fall into two (rarely more) groups, which I want to consider differently in some cases. An example is the abstract tree node and various implementations of branches and leaves, where I want to highlight branches and leaves at some point.
These intermediate classes are then used only for "is-a" statements in flow control, and they do not contain any code, although I had cases when they "grew up" in some code later.
Does that sound smelly to you? In my example on a tree, one alternative would be to add abstract methods isLeaf()/ isBranch()to the base class and implement them on intermediate classes, but for me this did not seem to be better, d means that there can be several classes at once.
source
share