Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [cohesion]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
5 answers
471 views

What is the right understanding for cohesion and coupling?

I'm trying to better understand cohesion and coupling. More specifically, I'm trying to use examples to better cement the concepts and one of the most common examples I see goes something like this. ...
SuperJumbo's user avatar
3 votes
2 answers
358 views

When refactoring many functions that share state in to a single class, how can you avoid writing an "escort" class?

This well-known article criticises Java on the basis that it does not allow you to write functions that do not live in a class. This flaw forces you to write classes with names that look suspiciously ...
J. Mini's user avatar
  • 1,007
-1 votes
2 answers
214 views

Performance hit after non-functional refactoring

I was asked to refactor some C++ code recently for the purposes of increasing unit testing coverage. The problem was that the code was tightly coupled on one compilation unit, so we had the equivalent ...
Component 10's user avatar
1 vote
2 answers
131 views

How to maintain cohesion, loose coupling, and SRP when building a reporting tool?

I'm building a reporting tool with three core layers: Extract data from a database Transform this data to compute business metrics Display these metrics in a report (a heavily formatted Excel export ...
Myccha's user avatar
  • 119
2 votes
0 answers
154 views

Cohesion and coupling possible combination in software

I know what we mean by cohesion and coupling in software. And generally the best practice is to achieve high cohesion with low coupling. It seems to me though that they are inter-related. I.e. you ...
Jim's user avatar
  • 327
2 votes
1 answer
261 views

Avoiding coupling through code sharing

I have been working on an application which consists of several cohesive services, Customer, Invoice, PurchaseOrder, Highlight, the application is deployed within a mono repo and each service is ...
berimbolo's user avatar
  • 123
0 votes
2 answers
349 views

About coupling and cohesion

At the end of this discussion about coupling and cohesion https://www.youtube.com/watch?v=hd0v72pD1MI some renowned programmers agreed in the general thought that to achieve high cohesion you have to ...
Leonardo Mangano's user avatar
-2 votes
1 answer
169 views

Achieving loose coupling

My scenario involves the following classes: I have three types of Peer that creates a RegistryType instance because its methods are needed. Same for Identity class. Each PeerType need 0 or all the ...
Antonio Santoro's user avatar
-1 votes
1 answer
222 views

New frontend for legacy code

How would you engineer this: You have a legacy application that is a big ball of mud and a monolith. This application is "impossible" to change to look good on mobile devices. The management ...
emajl's user avatar
  • 59
2 votes
2 answers
146 views

Use old legacy application code from new application

If you have a big legacy application (big ball of mud), lets call it MudApp. If you then create a new application to make us of new technology and to make a new good looking frontend because that was ...
emajl's user avatar
  • 59
1 vote
4 answers
395 views

Is there multiple definitions for responsibility of class?

In the book UML 2 and the Unified Process from Arlow and Neustadt has been told: Analysis classes should have 3 to 5 responsibilities But as you know we have the SRP that tells us something else!! ...
flexibleHammer's user avatar
-3 votes
1 answer
1k views

What is informational cohesion?

I try to understand what cohesion means when designing modules. Myers states in his book "Composite structured design": An informational-strength module has the following definition: It ...
flexibleHammer's user avatar
7 votes
1 answer
3k views

Concept of functional cohesion

I made some research to better understand the concept of functional cohesion. Myers in his book "Composite structured design" has written about functional cohesion: A functional-strength module is ...
flexibleHammer's user avatar
0 votes
1 answer
67 views

Directed Graphs

Conisder the following piece of code : cin >> a >> b; int x,y,z; x=0; y=1; z=1; if (a > b){ x = a*b; while (10 > a){ y=y+z; a=a+5; } else { x=x+b; } Its Directed graph is shown ...
John adams's user avatar
2 votes
0 answers
172 views

Packages, a controller class, and coupling vs cohesion

So I'm building my first application, in Python, and some issues have cropped up because of the lack of interfaces (I.e. explicit type declaration) My design involves several homebrew packages, and I'...
user309290's user avatar
5 votes
1 answer
933 views

Tight class cohesion metric, all or just public methods?

I am researching cohesion topic and found out that some claim TCC metric should only include public methods, some other sources claim all methods. Would it be wrong to use either approach? Why private ...
John V's user avatar
  • 4,938
1 vote
1 answer
86 views

How to implement a large algorithm with mostly unrelated steps while maintaining cohesion

I want to implement something similar to the algorithm described here. I don't even know if "algorithm" is the right word, since many of the steps are considered to be algorithms themselves. What I've ...
Gaston Gilbert's user avatar
1 vote
1 answer
120 views

Packages : opposing forces of reusability and developability

In choosing the classes to group together into packages, we must consider the opposing forces involved in reusability and developability. Balancing these forces with the needs of the application ...
q126y's user avatar
  • 1,713
2 votes
6 answers
511 views

Object Design & Cohesion - Issue & potential refactoring

Abstract I have been trying to get my head around the cohesiveness of some functionality in our code base. I’ve approached this design in different ways, and lately I’m convinced that I took the ...
GetFuzzy's user avatar
  • 133
4 votes
1 answer
1k views

What is the evidence that an API has exceeded its orthogonality in the context of types?

Wikipedia defines software orthogonality as: orthogonality in a programming language means that a relatively small set of primitive constructs can be combined in a relatively small number of ways ...
hawkeye's user avatar
  • 4,829
11 votes
6 answers
4k views

Fields vs method arguments [closed]

I just started writing some new class and it occurred to me that I was adding a lot of method arguments that are not strictly needed. This is following a habit to avoid having state in classes that is ...
Jeroen De Dauw's user avatar
6 votes
2 answers
1k views

Does increasing the number of classes increase code complexity? [duplicate]

To illustrate the question, let's say we have two programmers of comparable skill that both solve the same problem. The code they turn out has roughly the same lines of code, but one programmer uses 5 ...
mortalapeman's user avatar
  • 1,613
3 votes
3 answers
2k views

Programming by Intention, Depth-First or Breadth-First?

Say I have the following graph of dependencies between procedures/functions/methods: o / \ v e / \ / \ r f l w That is, function o first calls function v, and then ...
fredoverflow's user avatar
  • 6,874
4 votes
7 answers
5k views

What's the opposite of cohesive?

I was talking with my architect about some concerns with a particular approach that may result in very low level of cohesion in a set of classes. However, I couldn't think of the word that represents ...
Justin Self's user avatar
12 votes
3 answers
9k views

What is logical cohesion, and why is it bad or undesirable?

From the c2wiki page on coupling & cohesion: Cohesion (interdependency within module) strength/level names : (from worse to better, high cohesion is good) Coincidental Cohesion : (...
user avatar
8 votes
3 answers
6k views

Low Coupling: Single Responsibility Principle vs Cohesion

I've read several articles on SRP and cohesion, and they seem to contradict each other as far as low coupling is concerned. Articles on cohesion argue that putting closely related responsibilities ...
user1483278's user avatar
  • 1,131
38 votes
9 answers
12k views

How to determine if a class meets the single responsibility principle?

The Single Responsibility Principle is based on the high cohesion principle. The difference between the two is that a highly cohesive classes features a set of responsibilities that are strongly ...
user1483278's user avatar
  • 1,131