aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes how to main a high cohension Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "how to main a high cohension" Watch "how to main a high cohension" New topic
Author

how to main a high cohension

Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

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


SCJP6.0,My blog Ranchers from Delhi
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

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


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

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.


SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to main a high cohension