(...a word in the RefactoringLanguage.)
(...or "Refactoring Concrete Class Into Polymorphic Implementation")
> Change all "ConcreteClass?" references to "NewInterfaceName?" ...except for object creation references ("news") Change these to "ImplementationClass?." > Run your UnitTests.(Don't tell me about Class-FactoryPattern-s! YouArentGonnaNeedIt! OK; if you need it later, you can HaveThisPattern -- the FactoryPattern, if you want. ;-)
This RefactoringPattern breaks a ConcreteClass? into an InterfaceDefinition? (AbstractBaseClass in some languages) and an ImplementationClass?.
You can follow this by adding alternate ImplementationClass?-es, each implementing the common InterfaceDefinition? to achieve Polymorphism.
You can extend with one of the several different types of FactoryPattern, allowing more flexible selection of an appropriate ImplementationClass? in each instance.
This pattern uses the simple RenameClass refactoring move, altering it slightly to factor out the reusable InterfaceDefinition?.