Simply Interface Segregation Principle states that: When a client depends upon a class that contains interfaces that the client does not use, but that other clients do use, then that client will be affected by the changes that those other clients force upon the class.
If you have a class that has two clients (objects using it):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
As you can see, our Car class has an interface that’s used partially by both the Driver and the Mechanic. We can improve our interface like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
So far so good, splitting the interface into two, we can comply to the Interface Segregation Principle. That’s it!!! See ya!!! :)