Forums Register Login

how to main a high cohension

+Pie Number of slices to send: Send
I was studing the cohension...but not able to understand how to maintain it......
as there are ways for strong encapsulation like we have to make the variable as private etc..

Is there something like this by which we can have a higher cohension.........


Thanks in advance
+Pie Number of slices to send: Send
Cohesion has to do with the responsibilities of a given class.

Encapsulation has to do with data hiding and making sure references do not leak from your class. Immutability is a related topic of interest
+Pie Number of slices to send: Send
 

phil sohar wrote:I was studing the cohension...but not able to understand how to maintain it......
as there are ways for strong encapsulation like we have to make the variable as private etc..

Is there something like this by which we can have a higher cohesion.........


Thanks in advance



Take a look on following pseudo code example:
In the above design cohesion is low the class is responsible to handle printing stuff sending emails and blah blah...such design is typically much difficult to maintain. High cohesion is all about how a single class is designed; the more focused a class the higher its cohesion.

Following listed code is high cohesion version of above example.

The key benefits of High cohesion is the code is easily reusable and easier to maintain for future changes.


hope this helps

Minhaj.
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 752 times.
Similar Threads
Cohension - Service Locator
Took the beta
cleared scjp 1.5 with 76%
coupling is lowered, and cohesion is increased
Display Tags in JSF
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 08:17:09.