In a recent job interview for position of junior developer this was one of the questions- what do the terms "coupling" and "cohesion" mean? I had no idea. Can anybody help?
Joined: Sep 15, 2000
Coupling and coehesion are term used in the design of software modules. Coupling - is the degree of interaction b/w the different modules in the s/w. (inter- modular) Cohesion- is the degree of interaction(binding) b/w parts of the same module.(intra-modular).
Good s/w design practice saus that the coupling should be minimum and cohesion must be maximum. (ps- correct me is i am wrong in this regard). Hope thats helps.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Joined: Nov 03, 2000
Good stuff, I have a few questions for you Rajesh to help me understand. So is coupling as simple as an object holds a reference to another object? I can see that there might be one way coupling and two way. Or is that de-coupled? For instance a Framework might know about, and execute methods on a object, but the object is decoupled, because it knows nothing of the framework. Is that correct? Is coupling usually a two way dependency, or do say one object is couple to another, while the other is decoupled? I'm suprised to hear that they asked that question for a Junior Developer pos... I know guys who claim to be Senior Developers who don't know this stuff. I bet meena is more senior then some of the seniors I know... ------------------ David Roberts, SCJP2 [This message has been edited by David Roberts (edited March 31, 2001).]
author of:<br /><a href="http://www.amazon.com/exec/obidos/ASIN/0201485672/electricporkchop" target="_blank" rel="nofollow">Refactoring : Improving the Design of Existing Code</a><br /><a href="http://www.amazon.com/exec/obidos/ASIN/020165783X/electricporkchop" target="_blank" rel="nofollow">UML Distilled, Second Edition: A Brief Guide to the Standard Object Modeling Language</a><br /><a href="http://www.amazon.com/exec/obidos/ASIN/0201895420/electricporkchop" target="_blank" rel="nofollow">Analysis Patterns : Reusable Object Models</a><br /><a href="http://www.amazon.com/exec/obidos/ASIN/0201710919/electricporkchop" target="_blank" rel="nofollow">Planning Extreme Programming</a>
Joined: Apr 04, 2001
For a real good discussion of coupling and cohesion I would read a book called Code Complete. It talks about the various types of coupling (data, time, etc.) and why they are bad. Basically coupling has to do with the concepts that are the oppositie of encapsulation. Modules that have knowledge of each others data, Modules that must be executed in a certain sequence are a couple of examples of coupling.