January 2020
Intermediate to advanced
640 pages
16h 56m
English
Similar to the SRP, the interface segregation principle (ISP) was also coined by Robert Martin. According to this principle, clients should not be forced to depend upon the interfaces that they do not use.
This principle is quite important as it forms the basis for applying the other principles we've discussed so far. Going back to our previous RPG example, let's assume that we have augmented our Sword object with a few more interesting methods:
// Sharpen increases the damage dealt by this sword using a whetstone. func (Sword) Sharpen() { //... } // MakeBlunt decreases the damage dealt by this sword due to constant use. func (Sword) MakeBlunt(){ //... } // Drop places the sword on the ground allowing others to pick ...