Which means "low grip and high grip"

I have trouble understanding the statement low in coupling and high in cohesion . I have googled and read a lot about it, but still hard to understand.

As far as I understand, High cohesion means that we must have classes specialized to perform a certain function. Hope this is correct? Like a credit card verification class that specializes only in credit card verification.

And still don’t understand what low connection means?

+116
oop ooad
Dec 22
source share
12 answers

I believe that:

Connectivity refers to the degree to which the elements of a module / class are related to each other. It is assumed that the linked code should be close to each other, so we should strive for high consistency and link the entire linked code as close as possible to each other. This is due to the elements inside the module / class.

Linking refers to the extent to which different modules / classes are dependent on each other. It is assumed that all modules should be as independent as possible, therefore low communication. This is due to the elements between different modules / classes.

To visualize the whole picture it will be useful:

enter image description here

The screenshot was taken from Coursera .

+186
Dec 22 '12 at 7:32
source share

Cohesion in software development, as in real life, consists in how much the elements consisting of a whole (in our case, let the class say), we can say that they really belong to each other. Thus, this is an indicator of how strongly each functionality expressed by the source code of a software module is connected.

One way to look at cohesion in terms of OO is that the methods in the class use any private attributes.

Now the discussion is more than High Cohesion (or the best type of adhesion - functional cohesion) when the parts of a module are grouped because they all contribute to one clearly defined module task.

A connection in simple words is how much one component (again, imagine that a class, although not necessarily) knows about the internal actions or internal elements of another, that is, how much knowledge it has on another component.

Loose communication is a method of connecting components in a system or network so that these components are at least practically possible ...

I wrote a blog post about this. He discusses all of this in detail with examples, etc. It also explains the benefits of why you should follow these principles.

+32
Apr 08 '15 at 19:32
source share

In software development, high cohesion means that a class must do one and one thing well. High cohesion is closely linked to the principle of shared responsibility .

Low coupling suggests that a class should have as few dependencies as possible. In addition, the dependencies that must exist should be weak, prefer dependency on an interface rather than on a particular class, or composition rather than inheritance.

High cohesion and low bond give us better designed code that is easier to maintain.

+17
Feb 10 '16 at 8:09
source share

Low traction is associated with two or more modules. If a change in one module leads to many changes in another module, then they are said to be highly related. This is where front-end programming helps. Any change in the module will not affect the other module, since the interface (the average value of the interaction) between them has not changed.

High cohesion. Put similar things together. Therefore, the class must have a method or behavior to do the related work. Just to give an exaggerated bad example: an implementation of the List interface should not have String-related operations. The String class must have methods, fields related to String, and in the same way, the List implementation must have the appropriate things.

Hope this helps.

+9
May 7 '14 at
source share

Short and clear answer

  • High cohesion : elements in one class / module must functionally connect and do one specific thing.
  • Weak connection : there should be minimal dependency between different classes / modules.
+6
Apr 24 '18 at 11:56
source share

In short, low adhesion, as I realized that components can be replaced without affecting the proper functioning of the system. Basicaly modulates your system into functional components that can be updated individually without disrupting the system.

+5
Dec 22
source share

Do you have a smartphone? Is there one big application or many small ones? Does one application respond to another? Can you use one application when installing, updating and / or uninstalling another? The fact that each application is self-sufficient is highly connected. The fact that each application is independent of the others is a low connection. DevOps supports this architecture because it means that you can perform discrete continuous deployment without compromising the integrity of the entire system.

+4
Jun 29 '17 at 20:22
source share

Low traction and high cohesion are recommended.

Linking means that different modules are interdependent and how other modules influence the change of some / significant module functionality. Low traction is emphasized because dependency must be kept low so that the most minor / minor changes will be made to other modules.

+1
Jan 22 '14 at
source share

An example may be useful. Imagine a system that generates data and puts it in a data warehouse, either a file on disk or a database.

High cohesion can be achieved by separating the data warehouse code from the data production code. (and actually separates disk storage from database storage).

Low traction can be achieved by ensuring that data production does not have unnecessary knowledge about the data warehouse (for example, it does not query the data store for file names or db connections).

+1
Nov 16 '16 at 12:35
source share

Inheritance or generalization is an example of high linkage (i.e., high interdependence). By this, I mean that in inheritance, often the parent class defines the basic functionality that its child class uses, and changing the methods of the parent class directly affects its child classes. Therefore, we can say that there is a large degree of interdependence between classes.

Implementing or using an interface is an example of high cohesion (i.e., low interdependence). This means that the interface puts forward a contract for any class that implements it, but each class has the right to implement methods declared in the interface in its own way, and changes to the method declared in one class do not affect any other class.

+1
May 23 '17 at 16:37
source share

Cohesion - how closely everything is connected with each other.
Clutch - how everything is connected to each other.

Let's take an example - we want to design a car for independent driving.

(1) We need a motor for proper operation.

(2) We need a car to drive on our own.

All classes and functions (1) of starting the engine and its operation work perfectly together, but do not help to drive the car. Therefore, we place these classes behind the motor controller.

All classes and functions in (2) work perfectly to make the car steer, accelerate and brake. They do not help the car start or send gas to the pistons. Therefore, we place these classes behind our own driving controller.

These controllers are used to communicate with all available classes and functions. The controllers then only communicate with each other. This means that I cannot call a function in the piston class from the gas pedal class to make the car move faster.

The pedal class should ask the driving controller to talk to the engine controller, which will then tell the piston class to move faster. This allows us, programmers, to find problems and combine large programs without worrying. This is because all the code worked behind the controller.

+1
Apr 30 '18 at 3:25
source share

Here is the answer to a bit of an abstract theoretical graph:

Let's simplify the task by just looking at the (directional) dependency graphs between state objects.

The extremely simple answer can be illustrated by considering two limiting cases of dependency graphs:

1st limiting case : cluster graphs .

The cluster graph is the most perfect implementation of the dependency graph with high cohesion and low coupling (taking into account the set of cluster sizes).

The dependence between clusters is maximum (fully connected), and the intercluster dependence is minimal (zero).

This is an abstract illustration of the answer in one of the limiting cases .

The 2nd limiting case is a completely connected graph, where everything depends on everything.

Reality is somewhere in the middle, the closer to the cluster graph, the better, in my humble understanding.

From another point of view : when looking at a directed dependency graph, ideally it should be acyclic, if not, then the cycles form the smallest clusters / components.

One step up / down the hierarchy corresponds to the “one case” of weak connection, close cohesion in software, but this principle of weak connection / close cohesion can be considered as a repeating phenomenon at different depths of an acyclic oriented graph (or one of its spanning tree).

Such a decomposition of the system into a hierarchy helps to overcome exponential complexity (say, in each cluster, there are 10 elements). Then on 6 layers this is already 1 million objects:

10 clusters form 1 supercluster, 10 superclusters form 1 supercluster, etc. .... without the concept of close cohesion, weak connection, such a hierarchical architecture would be impossible.

So this may be the real importance of the story, and not just a low bond with high cohesion in only two layers. The real importance becomes clear when considering abstractions of a higher level and their interaction.

+1
Aug 22 '18 at 17:31
source share



All Articles