Compare the Difference Between Similar Terms

Difference Between

Home / Technology / IT / Programming / Difference Between Coupling and Cohesion

Difference Between Coupling and Cohesion

June 14, 2011 Posted by Indika

Coupling vs Cohesion

Coupling and cohesion are two concepts found in Java (and all other object oriented languages). Coupling measures how much each of the program modules are dependent on the other program modules. Cohesion measures how strongly each of the functions are related within a module. Actually, any object oriented language (including Java) has the two main objectives of increasing cohesiveness and decreasing the coupling at the same time, in order to develop most efficient programmes. These two software engineering metrics were developed by Larry Constantine to reduce the cost of modifying and maintaining software.

What is Cohesion?

Cohesion measures how strongly each of the functions are related within a program module. Well structured classes lead to highly cohesive programs. If a certain class is performing a set of highly related functions, that class is said to be cohesive. On the other hand, if a class is performing a bunch of totally unrelated functionalities that means the class is not cohesive at all. It is important to understand that not having cohesiveness does not mean that the overall application does not have the required functionality. It’s just that without cohesion, it will be very difficult to mange the functionality because they will be scattered in many wrong places as the complexity of the application increases over time. Maintaining, modifying and extending behaviors scattered all over the code is very tedious even for the most experience programmers.

What is Coupling?

Coupling measures how much each of the program modules are dependent on the other program modules. Interactions between two objects occur because there is coupling. Loosely-coupled programs are high in flexibility and extensibility. Strong coupling is never good because one object can be highly dependent on some other object. This is a nightmare when the code is modified, because high coupling means that the programmers need to work on several places of code for even a single behavioral modification. Strong coupling always leads to programs with low flexibility and less scalability/extensibility. However, in programming languages like Java, completely avoiding coupling is impossible. But it is recommended that the programmers give their best effort to reduce the coupling as much as possible. It is also possible to have some coupling to help objects interact with each other without hampering its scalability and flexibility.

What is the difference between Coupling and Cohesion?

Even though coupling and cohesion deal with the quality of a module in software engineering, they are entirely different concepts. Cohesion talks about how much the functionality are related to each other within the module, while coupling deals with how much one module is dependent on the other program modules within the whole application. In order to have the best quality software, cohesion and coupling should reach the two opposite ends of their spectrums. In other words, loose coupling and strong cohesion provides the best software. Having private fields, non-public classes and private methods provide loose-coupling, while making all members visible within the class and having package as the default visibility provide high cohesion.

Related posts:

Difference Between JSP and Servlets Difference Between Graph and Tree Difference Between Object Oriented Programming and Procedural Programming Difference Between Encapsulation and Abstraction Difference Between Enumeration and Iterator

Filed Under: Programming Tagged With: cohesion, cohesive, cohesiveness, Coupling, Java, Larry Constantine, loose coupling, object oriented language, software engineering metrics, Strong coupling

About the Author: Indika

Indika, BSc.Eng, MSECE Computer Engineering, PhD. Computer Science, is an Assistant Professor and has research interests in the areas of Bioinformatics, Computational Biology, and Biomedical Natural Language Processing.

Leave a Reply Cancel reply

Request Article

Featured Posts

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and SARS

Difference Between Coronavirus and SARS

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Covid 19

Difference Between Coronavirus and Covid 19

You May Like

Difference Between General Relativity and Special Relativity

Difference Between General Relativity and Special Relativity

Difference Between Remote Desktop and VNC

Difference Between Attitude and Character

Difference Between Anodic and Cathodic Polarization

Difference Between Anodic and Cathodic Polarization

Difference Between Cabinet Minister and State Minister

Difference Between Cabinet Minister and State Minister

Latest Posts

  • Difference Between Serine and Tyrosine Recombinase
  • Difference Between Suspending Agent and Emulsifying Agent
  • Difference Between LAMP and PCR Test
  • Difference Between Miscible and Immiscible Liquids
  • Difference Between Uniformitarianism and Catastrophism
  • Difference Between Dispersion and Scattering of Light
  • Home
  • Vacancies
  • About
  • Request Article
  • Contact Us

Copyright © 2010-2018 Difference Between. All rights reserved. Terms of Use and Privacy Policy: Legal.