How do you define a Single Responsibility?

前端 未结 13 1794
醉酒成梦
醉酒成梦 2021-01-30 09:23

I know about \"class having a single reason to change\". Now, what is that exactly? Are there some smells/signs that could tell that class does not have a single responsibility?

相关标签:
13条回答
  • 2021-01-30 09:49

    A simple and practical method to check single responsibility (not only classes but also method of classes) is the name choice. When you design a class, if you easily find a name for the class that specify exactly what it defines, you're in the right way. A difficulty to choose a name is near always a symptom of bad design.

    0 讨论(0)
提交回复
热议问题