Home > Refactorings > Refactorings – Extract Interface

Refactorings – Extract Interface

October 25th, 2010

Extract Interface is a refactoring that provides an easy way to create a new interface with members that originate from an existing class or struct.

When several clients use the same subset of members from a class or struct, or when multiple classes or structs have a subset of members in common, it can be useful to embody the subset of members in an interface. The Extract Interface will help to create the new interface for you. Just place the caret on the type name and perform a refactoring.

Extract Interface generates an interface above the type it is performed on, and makes the current type implement this interface. A new interface name is automatically linked with the current type ancestor, so you can easily rename the newly created interface. If you would like to move the new interface to its own file, use the Move Type to File refactoring.


Refactor! Extract Interface preview

Result interface:

Refactor! Extract Interface result

The refactoring doesn’t have additional options.

Products: Refactor! Pro
Versions: 10.1 and up
VS IDEs: any
Updated: Jan/19/2010
ID: R017

Similar Posts: