The first refactoring we're going to see is the collapse hierarchy
refactoring. When a software system undergoes a number of changes, over
time the collapse hierarchy may become, let's say, sub-optimal. There are
several refactorings that address this
issue for example, refactorings that allow
you to move methods and fields up and down the class
hierarchy. So what happens when you apply a number of these
refactorings, is that a subclass might become too similar to its
superclass and might not be adding much value to the system.
In this case, it is a good idea to merge
the classes together. That's exactly what the Collapse Hierarchy refactoring
does. Imagine, for instance, that we have two classes: employee
and salesman. And that salesman is just so similar to
employee that it does not make sense to keep them
separated. In this case, you could merge the two classes,
so that at the end of the refactoring, only employee
is left. And the resulting structure of the system is improved.