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

Functions should do one thing #38

Closed
peter-gribanov opened this issue Aug 31, 2017 · 5 comments · Fixed by #170
Closed

Functions should do one thing #38

peter-gribanov opened this issue Aug 31, 2017 · 5 comments · Fixed by #170

Comments

@peter-gribanov
Copy link
Contributor

See Functions should do one thing.

Example is terrible.
My proposal for improvement was rejected #22
Need to think about how to make an example easier and better.

@peter-gribanov
Copy link
Contributor Author

Perhaps we should delete this section, because it's analogous of Single Responsibility Principle (SRP).

@TomasVotruba
Copy link
Contributor

Perhaps we should delete this section, because it's analogous of Single Responsibility Principle (SRP).

Agreed. The logic is basically identical + OOP promotes more robuts behavior

Could you send PR to delete https://github.com/jupeter/clean-code-php#functions-should-do-one-thing ?

@peter-gribanov
Copy link
Contributor Author

@TomasVotruba i create PR for this #170

@iainfogg
Copy link

Bob Martin's "Clean Architecture" book says that "a function should do one, and only one, thing" is different to SRP, I don't know if that sways your thinking about keeping this section? I'm new here, but I'd personally think it's good to keep, maybe with a better example as Peter suggested.

Of all the SOLID principles, the Single Responsibility Principle (SRP) might be the least well understood. That’s likely because it has a particularly inappropriate name. It is too easy for programmers to hear the name and then assume that it means that every module should do just one thing. Make no mistake, there is a principle like that. A function should do one, and only one, thing. We use that principle when we are refactoring large functions into smaller functions; we use it at the lowest levels. But it is not one of the SOLID principles—it is not the SRP.

@TomasVotruba
Copy link
Contributor

The logic is same for class/method/property, so it only needs to be said once.

See Occams razor.

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

Successfully merging a pull request may close this issue.

3 participants