Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single Responsibility Principle definition #906

Open
cGuille opened this issue Feb 15, 2022 · 1 comment
Open

Single Responsibility Principle definition #906

cGuille opened this issue Feb 15, 2022 · 1 comment

Comments

@cGuille
Copy link

cGuille commented Feb 15, 2022

Hello!

I have read the SRP definition on the website. As a reminder, here is how it is currently described:

#### Single Responsibility Principle
The Single Responsibility Principle is about actors and high-level architecture. It states that “A class should have
only one reason to change.” This means that every class should _only_ have responsibility over a single part of the
functionality provided by the software. The largest benefit of this approach is that it enables improved code
_reusability_. By designing our class to do just one thing, we can use (or re-use) it in any other program without
changing it.

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):

What do you think about this? Should we change the description of this principle on PHP the right way?

@f3ath
Copy link

f3ath commented Oct 9, 2022

I second this. SRP basically means that things which do not always change together (i.e. for different reasons) MUST NOT live together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants