0% completed
Restructuring the code to follow ISP
In the previous lesson, we saw how a bloated Printer interface violated the Interface Segregation Principle (ISP) by forcing classes to implement methods they didn’t need. To solve this, we will refactor the code to create smaller, more specific interfaces that only define the methods needed by each type of printer.
Step 1: Break the Large Interface into Smaller Interfaces
Instead of having a single large Printer interface, we can split it into more focused interfaces. Each interface will represent a specific functionality, allowing classes to implement only what they need.
Now,
.....
.....
.....
Gopi Kumar
· a year ago
Don't you think , interfaces is bloated here in the given example. For every methods , you are creating a interface. This should not be followed in real world system . I agree , we should make smaller interfaces , but we should not make interfaces for every functions.
Reading Progress
0%