High cohesion is when you have a class that does a well defined job. Low cohesion is when a class does a lot of jobs that don't have much in common.
Questions tagged [cohesion]
83 questions
90
votes
10 answers
What is high cohesion and how to use it / make it?
I'm learning computer programming and at several places I've stumbled upon the concept of cohesion and I understand that it is desirable for a software to have "high cohesion" but what does it mean? I'm a Java, C and Python programmer learning C++…

Niklas Rosencrantz
- 25,640
- 75
- 229
- 424
70
votes
6 answers
Coupling, Cohesion and the Law of Demeter
The Law of Demeter indicates that you should only speak to objects that you know about directly. That is, do not perform method chaining to talk to other objects. When you do so, you are establishing improper linkages with the intermediary…

Bradley Mazurek
- 941
- 9
- 9
37
votes
5 answers
Cohesion and Decoupling, what do they represent?
What are Cohesion and Decoupling? I found information about coupling but not about decoupling.

dbtek
- 928
- 2
- 12
- 14
30
votes
13 answers
Is it worth trying to write tests for the most tightly coupled site in the world?
Imagine that 90% of your job is merely to triage issues on a very massive, very broken website. Imagine that this website is written in the most tightly coupled, least cohesive PHP code you've ever seen, the type of code that would add the original…

Chris Bloom
- 3,526
- 1
- 33
- 47
21
votes
4 answers
Is "high cohesion" a synonym for the "Single Responsibility Principle?"
Is high cohesion a synonym for the Single Responsibility Principle? If not, how are they different?

user1483278
- 929
- 1
- 9
- 17
8
votes
5 answers
How do you manually compute for silhouette, cohesion and separation of Cluster
Good day!
I have been looking all over the Internet on how to compute for silhouette coefficient, cohesion and separation unfortunately, despite the resources, I just can't understand the formulas posted. I know that there are implementations of it…

asker
- 167
- 1
- 3
- 9
7
votes
2 answers
How to separate Swing GUI from Business Logic when Spring etc. is not used
please be advised, this is a long post. Sorry for that but I want to make my point clear:
I was wondering how to separate Swing GUI from Presentation and Business Logic for quite a long time.
At work I had to implement a 3 MD Excel Export for some…

Stefano L
- 1,486
- 2
- 15
- 36
7
votes
5 answers
embed multiple view controller in one window
I want to have a View which contains more than one view. see the below image:
as you see pageController controls page navigation and provide before and after viewController (page).
pageContentController displays text and process them.
soundPlayer…

Hashem Aboonajmi
- 13,077
- 8
- 66
- 75
6
votes
3 answers
optimization of high cohesion and loose coupling
I was questioned in a technical interview about cohesion and coupling of a project. I extensively explained their definitions, although I did not answer the second part of the question properly, as he said.
"How could we achieve a highly cohesive…

Ali K. Nouri
- 495
- 5
- 18
6
votes
5 answers
Handling large classes
I've recently begun coding in Java in the past few months. I have a Matrix class that's becoming much too bloated with a lot of methods. I also have a SquareMatrix class that extends Matrix, and reduces some of the bloat.
What I've found is that…

BLaZuRE
- 2,356
- 2
- 26
- 43
5
votes
4 answers
What is the Java standard for object cohesion? Does too much information in an object mean bad design? - see example
I'm creating a project which models an airport landing system. I have a plane object which stores all the information I need to sort the plane into a queue and store in a database. All the vital information is included in the object but I have also…

Zanarou
- 153
- 1
- 7
4
votes
5 answers
Good definition for "coherence"
I'm trying to tell someone his code is not "coherent" in the sense that it serves multiple purposes. I don't think I can explain it very well, so I'm looking for a good reference and/or definition.

allyourcode
- 21,871
- 18
- 78
- 106
4
votes
3 answers
Does an object capapble to save itself into DataBase spoils the Cohesion of the class?
Speaking in terms of object oriented design, do you think to give a functionality of saving itself into Data-base to an object spoils the COHESION of the class?
Imagine:
Product p = new Product()
{
Name = "Joy Rider",
…

pencilCake
- 51,323
- 85
- 226
- 363
4
votes
4 answers
Help with program design
I'm currently creating a simple console-based game in which the player can move between different rooms, pick up and use items, and eat food. In the game's current state that's about it.
What I need help with is:
Creating a good "Event" class for my…

bjrnt
- 2,552
- 3
- 27
- 38
4
votes
3 answers
Cohesion and Coupling - How does one determine the threshold?
I'm taking further intro java classes at the moment and this is how the class briefly defined this:
Cohesion: Aim for high cohesion, in this case cohesion meaning that a single module is tightly focused on its task.
Coupling: Aim for low coupling,…

simmonson
- 137
- 1
- 9