Coupling and cohesion

Jonathan picture Jonathan · Sep 2, 2008 · Viewed 41.7k times · Source

I'm trying to boil down the concepts of coupling and cohesion to a concise definition. Can someone give me a short and understandable explanation (shorter than the definitions on Wikipedia here and here)? How do they interact?

Thanks.

Anybody have a good, short example?

Answer

Shog9 picture Shog9 · Sep 2, 2008

Coupling

  • Loose: You and the guy at the convenience store. You communicate through a well-defined protocol to achieve your respective goals - you pay money, he lets you walk out with the bag of Cheetos. Either one of you can be replaced without disrupting the system.

  • Tight: You and your wife.

Cohesion

  • Low: The convenience store. You go there for everything from gas to milk to ATM banking. Products and services have little in common, and the convenience of having them all in one place may not be enough to offset the resulting increase in cost and decrease in quality.

  • High: The cheese store. They sell cheese. Nothing else. Can't beat 'em when it comes to cheese though.