Single Responsibility Principle definition
cGuille opened this issue · comments
Hello!
I have read the SRP definition on the website. As a reminder, here is how it is currently described:
php-the-right-way/_posts/06-03-01-Complex-Problem.md
Lines 27 to 33 in 4e688e0
I remembered reading a blog post a few weeks ago about how the idea that SRP meant "one class should only do one thing" was a misunderstanding of the principle.
Instead, the original meaning of this principle would be that only one "actor" should be able to cause a change in a given module (here a class), implying that if the module tries to address multiple business needs at the same time, those different business needs might end up conflicting and will make later changes harder.
So I don't think the SRP is about code reusability, I think it is about maintainability and ease of following business changes.
Here are a few posts I found about it (I cannot remember the post I originally read about this misunderstanding):
- http://www.softwareonthebrain.com/2022/01/the-misunderstood-single-responsibility.html
- https://www.e4developer.com/2018/10/04/single-responsibility-principle-do-you-know-the-real-one/
What do you think about this? Should we change the description of this principle on PHP the right way?
I second this. SRP basically means that things which do not always change together (i.e. for different reasons) MUST NOT live together.