Skip to main content
25 events
when toggle format what by license comment
Feb 19, 2021 at 3:00 history tweeted twitter.com/StackSoftEng/status/1362597923012431874
Feb 18, 2021 at 23:41 answer added codeasaurus timeline score: 2
Mar 19, 2016 at 9:17 history protected gnat
Mar 19, 2016 at 9:17 history edited gnat CC BY-SA 3.0
http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts
Mar 19, 2016 at 8:37 answer added Martin Maat timeline score: 1
Aug 28, 2012 at 17:15 vote accept user1483278
Aug 27, 2012 at 21:06 comment added user1483278 "Hm, I think the source of the confusion is the use of the word responsibility. Generally speaking high cohesion aims in grouping together related functionality that contributes to a single well defined task."That would make a sense, but (again I have no examples to base my question on) I assume lots of times classes with say two reasons to change can also be highly cohesive?! BTW, I apologize for dragging this topic
Aug 27, 2012 at 1:29 comment added yannis Hm, I think the source of the confusion is the use of the word responsibility. Generally speaking high cohesion aims in grouping together related functionality that contributes to a single well defined task. What SRP adds to the picture is a logical constraint: Your task is truly a single one, when there's only one reason for it to change. If what you define as "related responsibility" is in fact different (functional / logical) tasks, then your class is not a highly cohesive one, but a mess ;) There is such a thing as too much cohesion.
Aug 26, 2012 at 23:05 answer added Matthew Flynn timeline score: 17
Aug 26, 2012 at 22:44 comment added user1483278 @Yannis Rizos: "...not sure why or how the articles lead you to believe that SRP and high cohesion are somehow contradictory." Isn't it obvious? If putting related responsibility into highly cohesive class A reduces coupling, then putting those responsibilities out of A and into separate classes ( that adhere to SRP ) should have the opposite effect
Aug 26, 2012 at 22:43 comment added user1483278 @Yanis Rizos: "There are several closely related questions in the "related" section in the sidebar, please give them a quick read, " I didn't come here and ask the question as soon as it popped into my mind, I first read about 20 articles on the subject hoping to find an answer
Aug 26, 2012 at 22:12 comment added yannis There are several closely related questions in the "related" section in the sidebar, please give them a quick read, they and their answers will help clarify the principles a bit.
Aug 26, 2012 at 22:08 comment added yannis Highly cohesive classes usually reduce coupling, that's generally true (high cohesion often correlates with low coupling). SRP also can help reduce coupling, for more or less the same reasons as high cohesion, I'm not sure why or how the articles lead you to believe that SRP and high cohesion are somehow contradictory. If anything, I'd say that in a balanced design they are complementary, and in an unbalance one it doesn't matter, as you probably have bigger problems ;)
Aug 26, 2012 at 22:03 comment added user1483278 @Yannis Rizos: One article talks about high cohesion and that having highly cohesive classes usually reduces coupling( classes with several related responsibilities also fall under the umbrella of highly cohesive classes ), while other article talks about SRP and also mentions that SRP helps reduce coupling. I never claimed that there's a single article talking about both concepts.
Aug 26, 2012 at 21:52 comment added Robert Harvey Very closely related: programmers.stackexchange.com/q/160234
Aug 26, 2012 at 21:50 comment added yannis I'm confused, neither of the articles seem to propose anything similar to your claim, the second one doesn't even mention SRP.
Aug 26, 2012 at 21:40 comment added user1483278 Cohesion: megocode3.wordpress.com/2008/02 SRP: codebetter.com/karlseguin/2008/12/05/…
Aug 26, 2012 at 21:23 review Close votes
Aug 31, 2012 at 3:01
Aug 26, 2012 at 21:17 comment added yannis Well, it depends really, how about you point us to the articles you've read so we can see exactly what the authors had in mind?
Aug 26, 2012 at 20:46 comment added user1483278 May I ask whether my assumption about the two claims contradicting each other is correct ( assuming Highly_Cohesive_Class has more than one responsibility )?
Aug 26, 2012 at 20:10 comment added yannis Yes they are not synonyms, but they are very closely related ;) "high cohesion" is not a silver bullet, what you are looking for in your design, any design, is balance. If your design satisfies both principles, you are on the right path...
Aug 26, 2012 at 19:58 comment added user1483278 @Yannis Rizos: "Doesn't closely related imply that if they are going to change they are going to change for the same reason" According to some of the posts I've read, the two are not synonyms. In other words, we can have a highly cohesive class that doesn't have just a single responsibility and as such may change for several reasons, but it is still considered highly cohesive
Aug 26, 2012 at 19:48 comment added yannis High cohesion: Embedding closely related functionalities in a class, SRP: There should never be more than one reason for a class to change - Doesn't "closely related" imply that if they are going to change they are going to change for the same reason? How can they be closely related if not?
Aug 26, 2012 at 19:39 history edited user1483278 CC BY-SA 3.0
added 231 characters in body
Aug 26, 2012 at 19:32 history asked user1483278 CC BY-SA 3.0