Extracting Interfaces
To better understand the Extract Interface operation, let’s look at an example. Suppose you review your code and notice that a number of your domain objects share similar properties and methods. Let’s say the objects Invoice
, Order
, and Product
all contain properties for Id
and Name
and methods for Save
and Delete
. In this case, you should consider extracting this commonality into a standard interface that each of your domain objects would implement. Let’s look at how the Extract Interface refactoring operation aids in this regard.
First, you position your cursor on the target class whose members you want to extract. In the example, choose the Invoice
class and position the cursor on the class name. Then press Ctrl+. to ...
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.