![]() In the beginning, the project used the BasicCoffeeMachine class to model a basic coffee machine. Let’s take a look at a simple example where this happened. That’s often the beginning of interface pollution, which sooner or later leads to bloated interfaces that contain methods implementing several responsibilities. It’s tempting to add a new method to an existing interface even though it implements a different responsibility and would be better separated in a new interface. But from a technical point of view, the implementation of each change bears a risk. But it happens quite often that an application gets used for multiple years and that its users regularly request new features.įrom a business point of view, this is a great situation. None of us willingly ignores common design principles to write bad software. Violating the Interface Segregation Principle Similar to the Single Responsibility Principle, the goal of the Interface Segregation Principle is to reduce the side effects and frequency of required changes by splitting the software into multiple, independent parts.Īs I will show you in the following example, this is only achievable if you define your interfaces so that they fit a specific client or task. Sounds obvious, doesn’t it? Well, as I will show you in this article, it’s pretty easy to violate this interface, especially if your software evolves and you have to add more and more features. “Clients should not be forced to depend upon interfaces that they do not use.” Martin while consulting for Xerox to help them build the software for their new printer systems. The Interface Segregation Principle was defined by Robert C. Definition of the Interface Segregation Principle So let’s focus on the Interface Segregation Principle. I already explained the Single Responsibility Principle, the Open/Closed Principle, and the Liskov Substitution Principle in previous articles. Martin defined the following five design principles with the goal to build robust and maintainable software: You might even argue that the microservices architectural style increased their importance because you can apply these principles also to microservices. Even though these principles are several years old, they are still as important as they were when he published them for the first time. The Interface Segregation Principle is one of Robert C.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |