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
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…

Mislav Niko Zaloker
- 43
- 1
- 5
4
votes
2 answers
Turning sequential cohesion into functional cohesion?
As described on this website,
A module with (only) procedural cohesion is one supporting different and possibly unrelated activities, in which control passes from one activity to the next. Page-Jones gives an example of a module (whose name might…

x1886x
- 1,217
- 2
- 12
- 21
3
votes
8 answers
Class design: change text on button click
I have 2 classes for the game I am making: a gui class and the logic class, for a game of noughts and crosses. The GUI class has a method that uses an array of JButtons and returns them all with the same anonymous inner class action listener.
When I…
Roberto Duran
3
votes
0 answers
Is there a PHP linter that can restrict class imports based on custom boundary rules?
We have a monorepo that includes our old monolith as well as our new modules. (We don't want separate repos...yet)
src/Monolith/...
src/OrderModule/...
src/PaymentModule/...
We obviously don't want our new modules coupled to the monolith. We also…

Matt Janssen
- 1,505
- 13
- 14
3
votes
2 answers
What is difference between procedural cohesion and sequential cohesion in Software Design Architecture?
Procedural cohesion says Parts of a module are grouped because they
always follow a certain sequence of execution
and Sequential cohesion says Parts of a module are grouped because the output from one part is the input to another
part like an…

Usama
- 231
- 1
- 4
- 8
3
votes
2 answers
Remove coupling and then mock for unit test
This is a dilemma. Say we have two classes
Class A
{
public int memberValue;
}
interface IB
{
int fun();
}
Class B : IB
{
public int fun()
{
var a = new A();
switch(a.memberValue)
{
case 1:
…

dushyantp
- 4,398
- 7
- 37
- 59
2
votes
1 answer
Tools for measuring coupling and cohesion
Do you know of any tools that help us measure coupling and cohesion in the system?

noobcoder
- 23
- 1
- 3
2
votes
2 answers
Cohesion VS. Coupling
This question will treat software like a tree, where:
Each node in the tree represents some code unit (eg class \ method \ line etc.)
Node X is son of Node Y if in the source code X is set in Y
Here is the definition of the term T:
T relative to…

idan mor
- 23
- 3
2
votes
1 answer
Keeping Coupling Low While Adhering to DRY
The mantra "Keep high cohesion and low coupling" (or some variant) is frequently tossed around. However, I find that it frequently conflicts with "Don't repeat yourself."
For example, I think we can all agree that it's a bad thing to re-implement…

Maxpm
- 24,113
- 33
- 111
- 170
2
votes
4 answers
Improving Cohesion and Coupling of Classes
I am given this set of code and need to suggest ways to improve the code's cohesion and coupling of the classes. But I thought these classes are quite well de-coupled since it looks like they are making use of events. And in terms of cohesion, all…

Carven
- 14,988
- 29
- 118
- 161
2
votes
1 answer
When does improving program cohesion worsen coupling?
I recently took an exam on design principles & patterns, and one of the questions in the exam was as follows : "Sometimes improving program cohesion may worsen coupling, give an example."
From what I understand, cohesion is how focused a…

Some Student
- 67
- 5
2
votes
1 answer
Is this considered low coupling & high cohesion? Any chance to improve?
I'm trying to get hold of the SOLID principles by Robert C. Martin. Currently I'm looking into low coupling & high cohesion. I've created some code which represents my current understanding of this subject. Could you guys tell me if on the right…

M. Groenhout
- 386
- 2
- 10
2
votes
3 answers
Communication cohesion
There are coupling and cohesion for modules. OK. There are functional and communication cohesion. Functional cohesion is grouping by functionality. OK. Communication cohesion is grouping by input/output data.. Hm.. Not OK. Can any explain me what is…

Stan Kurilin
- 15,614
- 21
- 81
- 132
2
votes
3 answers
Which is "better" practice? Passing object references or object method references in Python
I'm writing a small piece of code in Python and am curious what other people think of this.
I have a few classes, each with a few methods, and am trying to determine what is "better": to pass objects through method calls, or to pass methods through…

Corey D
- 4,689
- 4
- 25
- 33
2
votes
1 answer
SRP: Why use instance field values instead of parameters?
I've just read SRP, as easy as 123…, and all of it resonates with me except one paragraph, in a section named "Cohesion" (I've claimed before to "get" Cohesion, but this talk of parameters vs instance fields gives me pause...):
Take your class.…

lance
- 16,092
- 19
- 77
- 136