Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About cohesion in Java

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

all these is theory i found about Cohesion class in Java .

High-cohesion means well-structured classes .

Cohesive means that a certain class performs a set of closely related actions.
A lack of cohesion, on the other hand, means that a class is performing several unrelated tasks
Though lack of cohesion may never have an impact on the overall functionality of a particular class


Can i get an example for this type of behaviour of a class??

Thanks .

 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lets say that you have a hotel management program and that it has a class Manager that handles the checking in and out of customers and also the registering of customer.
That class has low cohesion. It would be much better to have 2 classes. One that handles checking in and out and the other one of registering customers.
Because then the have a high cohesion.

You could also read this
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much .It was nice explanation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic