From the course: C# Practice: Interfaces and Abstract Classes

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Solution: Refactor a fat interface

Solution: Refactor a fat interface - C# Tutorial

From the course: C# Practice: Interfaces and Abstract Classes

Solution: Refactor a fat interface

- [Instructor] The code challenge was to refactor this large interface called IBigPrinter into smaller, leaner interfaces. So the first step that I did in my code was I commented out this interface IBigPrinter. Now, remember that it has one property called printer name, and two methods, one called PrintDoc and one called ScanDoc. Now, what I'm going to do is move each one of these items or each one of these members into a separate interface. So up here I created three new interfaces. One's called IPrintDevice and it's where I've defined the printer name property. Then I have IPrinter, which has PrintDoc, and IScanner, which has ScanDoc. Then I'm using a principle of a base interface, so this IPrint device is used as the base interface for IPrinter and for ScannerDoc. That way I only have to implement, or only have to define I should say, the printer name property in one spot. Once I've got my three skinny interfaces defined,…

Contents