Share via


c# what is Cohesion and coupling

Question

Friday, November 18, 2016 12:09 PM

any one can explain it with example that what is Cohesion and coupling and what is difference between them. thanks

All replies (6)

Friday, November 18, 2016 1:36 PM ✅Answered

Take a look at the first answer here: Cohesion-Coupling


Friday, November 18, 2016 1:38 PM ✅Answered

You can see  the old MSDN Article "Cohesion And Coupling" from Jeremy Miller


Saturday, November 19, 2016 3:53 AM ✅Answered

Hi Mou_kolkata,

Cohesion describe a structure inside a module. A good cohesive module should do exactly one thing. It describes the functional connections within the module.

Coupling describe a relationship between multi modules. The coupling strength depends on the complexity of the interface between the modules, the point of access to or access to a module and the data through the interface.

Hopping my reply is helpfu for you.

Best Regards,
Li Wang

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Friday, November 25, 2016 9:47 AM ✅Answered

Hi Mou_kolkata,

Thank you for posting here.

**>>what is Cohesion and coupling

Coupling - A measure of how much a module (package, class, method) relies on other modules. It is desirable to reduce coupling, or reduce the amount that a given module relies on the other modules of a system.

Cohesion - A measure of how closely related the members (classes, methods, functionality within a method) of a module are to the other members of the same module. It is desirable to increase cohesion as that indicates that a module has a very specific task and does only that task.

**>>what is difference between them

Cohesion

Coupling

Cohesion is the indication of the relationship within module.

Coupling is the indication of the relationships between modules.

Cohesion shows the module’s relative functional strength.

Coupling shows the relative independence among the modules.

Cohesion is a degree (quality) to which a component / module focuses on the single thing.

Coupling is a degree to which a component / module is connected to the other modules.

While designing you should strive for high cohesion i.e. a cohesive component/ module focus on a single task (i.e., single-mindedness) with little interaction with other modules of the system.

While designing you should strive for low coupling i.e. dependency between modules should be less.

Cohesion is the kind of natural extension of data hiding for example, class having all members visible with a package having default visibility.

Making private fields, private methods and non public classes provides loose coupling.

Cohesion is Intra – Module Concept.

Coupling is Inter -Module Concept.

For more information, you could refer to the link.

I hope this would be helpful to you.

If you have something else, please feel free to contact us.

Best Regards,

Wendy

MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].



Friday, November 18, 2016 12:07 PM

any one can explain it with example that what is Cohesion and coupling and what is difference between them. thanks


Friday, November 18, 2016 1:10 PM

As both are the same question in different I merged them together.

Thanks,
Sabah Shariq

[If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]