Given that Mixins typically introduce new behavior into a class, this usually implies that the class will have more than one behavior.
If a class has one responsibility, it is defined as a class having only one reason for the change.
So, I see it from two different sides.
A class has only one reason to change. The mixed module also has only one reason for the change. If the class is changed, the class will need to be retested. If the module is modified, the module needs to be retested. Therefore, the SRP is not damaged.
The class now has two reasons to change. If the class is changed, both the class and the module need to be retested. If the module is changed, then again both that class and the module need to be retested. Henge, SRP is being violated.
Does the use of mixins affect the principle of shared responsibility and ultimately lead to more difficult to maintain the system?
oop design-patterns mixins srp
Mongus pong
source share