I know what we mean by cohesion and coupling in software. And generally the best practice is to achieve high cohesion with low coupling.
It seems to me though that they are inter-related. I.e. you either end up with low cohesion/high coupling or high cohesion and low coupling.
Can we ever end up with high cohesion and high coupling or low cohesion and low coupling or it is impossible by definition? If it is possible what would be an example of high cohesion and high coupling? What would be an example of low cohesion and low coupling?
Although it is a language agnostic question, a Java example would be much welcome

  • Depends what you mean by "coupling". For a system to be useful, there has to be some coupling, otherwise, things can't communicate with each other, and the system can't do anything. So, what you want to avoid is unwanted coupling, which you can vaguely think of as being any sort of coupling that turns out to cause nontrivial problems across time, as changes need to be made. I'm inclined to think that this kind of coupling strongly correlates with low cohesion. It affects several "decoupled" components at once, or has ripple effects on dependent components == low cohesion. Nov 15 at 19:06
  • @FilipMilovanović: What you describe in the first sentence is not "coupling" but dependency. I think these terms are not the same and when one system/component relies on another system/component is a dependency but not (necessarily coupling). I guess coupling is a very strong form of dependency
    – Jim
    Nov 16 at 15:53
  • By the way why the close comment? Is the question not suitable for this stackexchange?
    – Jim
    Nov 16 at 15:55
  • Coupling, in the sense used in the "strong cohesion/low coupling", is referring to interdependencies (explicit, implicit, structural, temporal, ...), although sometimes the term "dependency" is used with a narrower meaning (e.g. explicit dependency in Dependency Injection). I wasn't the one who voted to close, so I can't be sure what the motivation was, but I can see that the person who did selected "needs more focus" as the reason, so perhaps they felt the question was too broad. Nov 16 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.