Questions tagged [cohesion]

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.

81 questions
83
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 R.
  • 22,209
  • 67
  • 202
  • 380
67
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
  • 891
  • 9
  • 9
35
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
  • 908
  • 2
  • 11
  • 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,383
  • 1
  • 29
  • 45
18
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?
8
votes
4 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
  • 2
  • 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,223
  • 1
  • 10
  • 31
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
  • 8,866
  • 7
  • 54
  • 64
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
  • 492
  • 4
  • 15
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
  • 83
  • 5
5
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,295
  • 2
  • 23
  • 40
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
  • 19,438
  • 17
  • 73
  • 100
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
  • 45,443
  • 73
  • 211
  • 346
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
  • 1,782
  • 3
  • 20
  • 32
4
votes
0 answers

Decreasing coupling and cohesion by facade pattern

For my Software Design class, I have to find out if it is possible to decrease coupling and decrease cohesion at the same time by using the Facade pattern? As you all probably know, when there is low coupling, the cohesion of the classes is high and…
1
2 3 4 5 6