rspec/rules/S1200/description.adoc

16 lines
676 B
Plaintext
Raw Normal View History

2020-06-30 12:47:33 +02:00
According to the Single Responsibility Principle, introduced by Robert C. Martin in his book "Principles of Object Oriented Design", a class should have only one responsibility:
2021-02-02 15:02:10 +01:00
2021-01-06 17:38:34 +01:00
____
2020-06-30 12:47:33 +02:00
If a class has more than one responsibility, then the responsibilities become coupled.
2020-06-30 12:47:33 +02:00
Changes to one responsibility may impair or inhibit the class' ability to meet the others.
2020-06-30 12:47:33 +02:00
This kind of coupling leads to fragile designs that break in unexpected ways when changed.
____
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
Classes which rely on many other classes tend to aggregate too many responsibilities and should be split into several smaller ones.
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
Nested classes dependencies are not counted as dependencies of the outer class.