And considering that SoC makes no attempt to include coupling or cohesion in its definition it demonstrates they are not the same thing.
I got a good chuckle from this. LOL!
Scott
So what you are saying is that by applying your definition of SRP it would be like transforming a log (a cohesive unit) into a bunch of shavings (a collection of useless fragments).
Most programmers I know (at least the intelligent ones) would prefer to work with cohesive units rather than a collection of useless fragments.
Did you get that Tony?
Scott
Not Robert C. Martin. This is from the book Clean Code:
Pages 139 - 140.
Oh brother.
No, the shavings would be all the methods and properties we could shave out of your monster class and it still be fulfilling its single responsibility. Btw, what was the single responsibility again?
Of course, those shavings would have to be glued back together in other cohesive units/ classes, like making plywood.
Scott
The aim of the game is to produce software which exhibits high cohesion and low coupling. If you cannot achieve that by following SoC then you have failed.
Doesnât back up your point at all. SoC and SRP are not the same thing.
Iâm just going to post this again because you still ignored it:
You have stated they are different:
You are saying âSRP includes something SoC does notâ. How does that make them âexactly the same conceptâ?
This can be shown in PHP as:
$SoC = 1;
$coupling = 2;
$cohesion = 4;
$SRP = $SoC + $coupling + $cohesion;
var_dump($SRP === $SoC);
Unless you can make that evaluate to true without making any of the values zero or negative (ie, meaningless or not actually included) or changing the definition of SRP so it doesnât include all 3 concepts, or changing the operator to something other than equality (You are saying they are EXACTLY THE SAME), then your point is null and void.
if your definition of SRP is correct then youâll be able to do the above. Otherwise your definition of SRP is wrong and your argument is lost.
Thatâs 9 times youâve been unable to answer this post, 9 times youâve proven yourself wrong.
Corrected.
Scott
Your analogy is flawed. Itâs transforming a log into short planks which could be pieced together to make a chair, a crate, a barrel, a bookshelf, a spice rack, a wardrobe or a table. Your log can only ever be a log.
But still very useful if I want to build a log cabin.
OH YES THEY ARE!
Not on its own. A log cabin is made up of lots of logs. In your analogy a âlog cabinâ is a âcohesive unitâ.
Saying âYes they areâ in the face of opposing evidence without providing a counter claim only serves to demonstrate that youâre wrong.
But the smallest unit in a modular OO system is still a class.
Just because a single class can be a module doesnât mean all modules are single classes
âAll sharks are fish therefore all fish are sharksâ
Which should follow SRP.
Scott
They are similar, not the same. SoC deals with the higher software architecture level (in most cases). SRP deals with the class level (in all cases).
Scott
So hopefully you two got the email from Derek Greer of Aspiring Craftsman ( http://aspiringcraftsman.com/2008/01/03/art-of-separation-of-concerns/ ) one of the articles Tony has been referencing. Thereâs a few important things he said. Hopefully he wonât mind me posting excerpts from his email here:
- Tonyâs class does not follow SRP
Based upon the size of the class alone, however, I will say that I doubt that it adheres to the SRP because itâs unlikely that the behavior represented therein would all need to change for the same reason. Iâve written a few articles where Iâve discussed the SRP in more detail if you care to check them out.
- SRP and SoC are not the same thing:
To this I would say that itâs possible for a given module to follow good Separation of Concerns in some areas while not following them in others. For example, a given module may encapsulate all the business logic of a given feature (as opposed to the display or persistence logic) while not separating different aspects of the business logic that would tend to change for different reasons (a SRP violation). In other cases a module may encapsulate all the user interface logic of a given application while not separating out the various features.
The concept of Separation of Concerns is a very general principle, so it isnât well suited as a pass/fail measurement of software. Design principles like those represented by the SOLID acronym are far more well-distilled principles in which we can speak more objectively about whether a given module is in adherence with the principle or not
Yep, this part says it all. You can have good SoC and still break SRP, so they simply canât be the same.
Scott