Info |
---|
The Interface Segregation Principle (ISP) is another principle of the SOLID acronym, a set of five principles of object-oriented programming and design. The principles make it easier to develop software that is easy to manage and maintain, and also to understand. |
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
The Interface Segregation Principle is a concept in object-oriented programming that can be explained with a simple analogy: Imagine a multi-purpose remote control with buttons for operating a TV, a sound system, and a gaming console. Now, if you only have a TV, it's unnecessary and confusing to have buttons for the sound system and gaming console. This remote would be much easier to use if it only had the buttons needed for each specific device. In programming, the Interface Segregation Principle suggests something similar:
So, in simple terms, the Interface Segregation Principle advises that it's better to have several smaller, more specific interfaces than one large, catch-all interface. This makes your code more modular, easier to understand, and avoids unnecessary dependencies. |
...
The Interface Segregation Principle states that clients should not be forced to depend on interfaces they do not use. In other words, it's about making fine-grained interfaces that are client-specific rather than having a single general-purpose interface.
...