Skip to main content

Questions tagged [cohesion]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
5 answers
478 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. ...
3 votes
2 answers
361 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 ...
-1 votes
2 answers
217 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 ...
1 vote
2 answers
133 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 ...
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 ...
2 votes
1 answer
264 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 ...
0 votes
2 answers
360 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 ...
-2 votes
1 answer
172 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 ...
39 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 ...
-1 votes
1 answer
223 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 ...
2 votes
2 answers
148 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 ...
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 ...
12 votes
3 answers
10k 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 : (...
1 vote
4 answers
402 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!! ...
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 ...
-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 ...
0 votes
1 answer
68 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 ...
2 votes
0 answers
173 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'...
5 votes
1 answer
937 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 ...
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 ...
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 ...
1 vote
1 answer
121 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 ...
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 ...
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 ...
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 ...
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 ...
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 ...