Is it correct to say that Encapsulation aims at Cohesion? Because?

5

Based on the statement below, my question follows:

  

Cohesion and Coupling are very software engineering principles   used. When we want to have a mature and sustainable architecture,   we must take these two principles into account, since each of them has   a specific purpose that aims to improve the design of the software. What   happens is that many people do not know the difference between them and   end up failing to get the benefits that put them into practice   at the time of designing the architecture of a software.

Source: Understanding Cohesion and Coupling - DevMedia

When I'm in the software architecture phase, basing myself on best practices, when I can build a cohesive, low-coupling class, can I say that encapsulamento targets coesão ?

    
asked by anonymous 06.11.2015 / 11:12

1 answer

3

Yes, encapsulation is a technique to achieve cohesion, although not the only one. And the encapsulation also has its own goals.

Obviously, attempting to carry the encapsulation to iron and fire can undermine cohesion. Cohesion is getting the balance. It is common to see the attempt to give more encapsulation and consequently to increase the coupling, lowering the cohesion.

Certainly exposing details that do not matter externally goes against the encapsulation and leaves the component less cohesive.

What are the concepts of cohesion and coupling?

    
06.11.2015 / 12:30