Difference between Single Responsibility Principle and Separation of Concerns

后端 未结 13 1398
-上瘾入骨i
-上瘾入骨i 2020-12-07 15:20

What is the difference between Single Responsibility Principle and Separation of Concerns?

13条回答
  •  长情又很酷
    2020-12-07 16:00

    Single Responsibility Principle (SRP)- give each class just one reason to change; and “Reason to change” == “responsibility”. In example: Invoice class does not have a responsibility to print itself.

    Separation of Concerns (since 1974). Concern == feature of system. Taking care of each of the concerns: for each one concern, other concerns are irrelevant. Hiding implementation of behavior.

    From here.

提交回复
热议问题