Pro EP 62 : Interface Segregation Principle of SOLID
What is Interface Segregation Principle from SOLID and how to implement it in C# ?
ISP is fourth and second last principle from SOLID principles. At some point ISP and SRP resemble.
ISP says :-
- Class should not be forced to depend on methods it doesn’t use
- Split a lengthy interface to small relevant interfaces
Benefits of ISP:-
- Modularity
- Reusability
- Maintainability
- Low coupled code
- Reduces the chances of defects
- Makes code easy to test and deploy independently
Example
Bad :- Single interface that is responsible card and bank payment processing even if someone would be interested in only one
Good :- Divide single interface to three different interfaces one to process payment and other two for bank and card
Whenever you’re ready, there are 4 ways I can help you
- Subscribe to my Weekly .NET Newsletter of C#/.NET with 7000+ Software Engineers.
- Promote yourself to 7000+ subscribers by Sponsoring my Newsletter
- Download my eBook at Gum Road which contains 30+ .NET Tips (With 2800+ Downloads)
- TTo get 100+ free and paid resources for learning C# and .NET visit this GitHub Repository