Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What's the meaning of loose coupling
Posted

Loose coupling is described here[^].
 
Share this answer
 
Nuri Ismail links to the Wikipedia article[^], which I think describes it fairly well. But if an analogy would help, think of going to a convenience store...

You walk into a convenience store, select the item you wish to buy, hand money to the clerk behind the counter, and walk out. Many other people perform this same action each day, and never have any other connection to the shop. The clerk may be replaced numerous times as well, without any significant change in how customers make their purchases. So long as both the clerk and the customer understand the relevant interfaces, they can interact effectively and efficiently without knowing anything else about one another.

Contrast this with the relationship between you and your employer: you may still interact through a large number of general-purpose interfaces, but it's usually more effective if you both know something about one another beyond what's explicitly stated in your contract.
 
Share this answer
 
v2
Coupling refers to the degree of direct knowledge that one class has of another. Loose coupling hence is knowing "less" about how the other class is doing something.

Loose coupling is generally preferred, because if class A is tightly coupled to class B and class B changes, class A would need some changes too.

Decoupling(or loose coupling) can be achieved by using simple programming constructs like interfaces etc.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900