Extract Interface

When classes contain the same subset of members, defining a common contract that each class shares can be useful. You do this, of course, via an interface. Some basic advantages to defining interfaces are that your code becomes more readable, is easier to maintain, and operates the same for like members. However, developers often don’t realize the commonality between their classes until after those classes are coded. This sometimes makes creating interfaces painful.

The Visual Studio code editor provides the Extract Interface refactoring operation to make this process easier. It enables you to take an existing class or struct and automatically generate a matching interface that the existing class then implements.

Get Microsoft Visual Studio 2015 Unleashed, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.