Interface Segregation Principle
Hey everybody it is fourth principle of SOLID Principles. This principle means that a client should never be forced to implement an interface that it doesn’t use, or clients shouldn’t be forced to depend on methods they do not use.
After the classical definition. For example, let’s say you have a restaurant and you have a chef. He is an excellent chef, he can cook anything you want. This chef can cook burgers, pizzas and kebabs and he has a assistant chef. Assistant can’t cook everything. He cannot cook pizza. If the assistant chef cannot cook pizza. We can’t expect him to make pizza or force him to make pizza.
Example Project
In order to learn in detail, the correct usage and the wrong usage should be examined together.
Wrong Usage :
We have cars and features. The features is breaking , going and drifting. We have two cars Nissan350Z and Renault12. Nissan can drift but Renault can not. So we should chance the architecture. We should not leave the drift func blank in the Renault class.
Correct Usage :
By separating the features, we added the features we wanted to the car we wanted. Thus, we have applied the Interface Segregation principle.
You can continue reading here :
Referances :
bolŞans…