In SOLID, what is the distinction between SRP and ISP? (Single Responsibility Principle and Interface Segregation Principle)

前端 未结 4 1796
情歌与酒
情歌与酒 2021-02-02 06:05

How does the SOLID \"Interface Segregation Principle\" differ from \"Single Responsibility Principle\"?

The Wikipedia entry for SOLID says that

IS

4条回答
  •  我在风中等你
    2021-02-02 06:16

    SRP and ISP ultimately boils down to the same things. Implementing, either of them, needs a split of classes or interfaces.

    However there are differences on other fronts.

    1. Violation of SRP can have a far reaching effects on the entire design structure, giving rise to poor maintainability, reuse and of course low cohesion and coupling.
    2. SRP has an impact on both the behavioral and structural components of an object structure.
    3. Re designing on SRP violation needs a much deeper analysis, require looking at the different components of design in a holistic way.

    Violation of ISP is mostly about poor readability ( and to some degree, low cohesion ). But the impact on maintenance and code re-use is far less sinister than SRP.

    Moreover, refactoring code to ISP conformation, seems to be just a structural change.

    See also my blog for SRP and ISP

提交回复
热议问题