Some features in the class are only used by some instances.Create a new subclass and move the features mentioned above to the subclass.
Motivation: the main motivation for using extract subclass is: You find that some behaviors in the class are only used by some instances, and other instances do not need them. Sometimes the difference in this behavior is identified by type codes. In this case, you can use replace type code with subclass (replace type code with subclass) or replace type code with State/Strategy (replace type code with State policy ). However, it is not necessary to have a type code to indicate that subclass needs to be considered.
Extract class(Refining class) is another choice outside of extract subclass (refining sub-class). The choice between two is actually the choice between delegation and inheritance. Extract subclass (extract subclass) is usually easier, but it also has restrictions: once an object is created, you cannot change the type-related behavior, however, if you use extract class, you only need to insert another component to change the behavior of the object. In addition, subclass can only represent a group of changes. If you want a class to change in several different ways, you must use the delegate.