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.

83 questions
0
votes
1 answer

C# Properties and standard class structural metrics

I'm trying to understand how the elementary class structural metrics, such as ATFD (access to foreign data) and LCOM (lack of cohesion in methods) are calculated in light of C# Properties. If a method access a single property of another class, does…
NLuburić
  • 912
  • 1
  • 10
  • 28
0
votes
0 answers

microservice paging with filter from other service. large cohesion

We're currently trying to break down our monolith in microservices and I have currently a problem with a use case. We have the following use cases/requests from the client The user can get bookdetails The user can manage private booknotes The user…
wydy
  • 173
  • 14
0
votes
1 answer

How to break a high cohesive model into different classes

I have a container in which 8 relais live. Now i want to let the client turn on/off different relais. So far so good. One solution could be: container.tryTurnOn(1, true); container.turnRandomOn(true); //turn relais random to on or not. The 1 means…
Robin Kreuzer
  • 162
  • 1
  • 10
0
votes
2 answers

Abstraction in business logic classes

When you call a method from a library you expect that it does exactly what its name implies it will do. Connection c = driver.getConnection(); to give back a connection to report an error if it fails not to do more than expected When writing…
AgostinoX
  • 7,477
  • 20
  • 77
  • 137
0
votes
1 answer

I don't understand why test[number-1] is duplicated and returns different boolean values

Here is a subcode of calculating if a given matrix is a magic square. I'm only confused with the test[element -1] that is duplicated and have two different returns. public static boolean testNormal(int[][] matrix, int dim){ int magicConstant =…
0
votes
1 answer

Coupling of objects

Assuming I have methods of doA(), doB() and doC() of classes A,B and C respectively. Than unless I am wrong, doA() method should belong to class A. It must be executed from Class A. If a method doA() that does the responsibilities for A, exists in…
user478636
  • 3,304
  • 15
  • 49
  • 76
0
votes
2 answers

Cohesion vs Single Responsibility

I've started to study concepts like Cohesion and principles like Single Responsibility Principle. I am very confused about the difference between them. The web has a lot of information, but I find it very difficult to filter out the correct…
0
votes
1 answer

Real life example of high cohesion and loose coupling for presentation

I need to do a presentation about high cohesion and loose coupling. To explain this to my audience, I need to come up with a real life example (not code-based) of those 2 terms and I kinda have difficulties to find one. Therefore I would like to ask…
Remo
  • 1,112
  • 2
  • 12
  • 25
0
votes
1 answer

calculating coupling and cohesion metrics from XML class diagrm

I am trying to create a project to provide decision making support for class responsibility assignment problem using particle swarm optimization. A fitness function is derived considering various parameters like coupling and cohesion and particle…
Sreeraj T A
  • 142
  • 1
  • 1
  • 9
0
votes
1 answer

Cohesion in methods - what about calculations and helper functions?

The assumption behind the cohesion metrics is that methods are related if they work on the same class-level variables. Methods are unrelated if they work on different variables altogether. In a cohesive class, methods work with the same set…
Pietross
  • 313
  • 1
  • 3
  • 9
0
votes
2 answers

How to make a design "loose coupling"?

I'm making a simple 3D CAD software. in the class diagram, many objects need to distinguish with others by (x,y,z). I create a class so-called "Position", but the problem is it looks highly-coupling because many classese work with position. Any…
SteveThai
  • 63
  • 1
  • 7
0
votes
3 answers

How can such a simple method be broken down and named?

Best practices dictate continuously that a method should be responsible for only one thing. I have come across a method that does 3 things, and I dont know how to 1. decompose it according to best practices. 2. name it. Also I wonder how many…
JavaDeveloper
  • 5,320
  • 16
  • 79
  • 132
0
votes
1 answer

Can adhering to the JavaBeans naming standard aid in achieving encapsulation?

Is it possible that java beans naming standards help in achieving encapsulation? Isn't it the access modifier that helps in encapsulation?
paidedly
  • 1,413
  • 1
  • 13
  • 22
0
votes
1 answer

How to refactor jqGrid code, from controller's JsonResult method, to loosely coupled models?

I'm using an example from Code Project: ASP.NET MVC-4,Entity Framework and JQGrid Demo with simple Todo List WebApplication. However, the developer didn't maximize cohesion since the the controller is doing all the business logic. I'm trying to…
0
votes
1 answer

Construct testable business layer logic

I am building an applications in .net/c#/Entity Framework that uses a layered architecture. The applications interface to the outside world is a WCF service Layer. Underneath this layer I have the BL, Shared Library and the DAL. Now, in order to…
JohanLarsson
  • 475
  • 1
  • 8
  • 23