I am trying to understand cohesion, but it looks similar to adhesion.
I want to know how cohesion is different from adhesion
Could you please give an example (basic English)?
I am trying to understand this from the computer science perspective.
English Language Learners Stack Exchange is a question and answer site for speakers of other languages learning English. It only takes a minute to sign up.
Sign up to join this communityI am trying to understand cohesion, but it looks similar to adhesion.
I want to know how cohesion is different from adhesion
Could you please give an example (basic English)?
I am trying to understand this from the computer science perspective.
Cohesion generally refers to the ability/tendency of a homogeneous substance or mixture of different things/ingredients to...
cohere - to hold together firmly as parts of the same mass
(alternate) - to be logically or aesthetically consistent
Adhesion generally relates to the ability of something to...
adhere - to stick to something : to attach firmly to something
(alternate) - to hold fast or stick by or as if by gluing, suction, grasping, or fusing
(Italics mine, to emphasize those aspects that normally distinguish the two words.)
Thus one could say that something exhibits cohesion all on its own (it stays together in a lump), but adhesion normally implies sticking to something else.
In the context of software, cohesion refers to the degree to which the elements of a module belong together. I'm not aware of any domain-specific sense of adhesion in the context of computing.
Cohesion has a specific meaning in Computer Science that relates to the similarity of elements within a larger system. While it is most commonly used in software engineering to describe how closely the methods of a class are related to the purpose of the class, it can also used in broader terms - you could say that the StackExchange family of communities are a quite cohesive system.
I've not heard of adhesion being used in relation to CS although adhere as a verb is used - we adhere (or, at least, we should try to) to standards.
So, you could say that "we adhere to best practice in OOP by ensuring that we write classes with with a high degree of cohesion."
I guess that you could mangle that sentence to use both adhesion and cohesion and still have it make sense, but it would sound awkward.
In my notes from my 2016 programming practices class, there's Coupling: The degree of reliance on other modules/functions. Cohesion: The degree to which a function adheres to one task.