You have a type code that affects the behavior of the class, but you cannot provide inheritance methods to eliminate it.Replace the type code with a status object.
Motivation: This reconstruction is similar to replace type code with subclass (replace type code with subclass, however, if the "type code changes in the object's lifecycle" or "The host class cannot be inherited for other reasons", you can also use this refactoring. This reconstruction uses the state mode and the Strategy Mode.
StateThe pattern is very similar to the Strategy pattern, so no matter which one you choose, the refactoring process is the same. "Which mode to select" is not the key to the problem. You only need to select a mode that is more suitable for a specific situation. If you want to simplify the process with replace conditional with polymorphism (replace conditional expressions with polymorphism) after This refactoringAlgorithmSelect the Strategy Mode. If you want to move the data related to the status and consider the new object as a change state, you should select the state mode.