| Author |
Low Cohesion or Tight Coupling?
|
Seema Gaurav
Ranch Hand
Joined: Apr 29, 2008
Posts: 47
|
|
Hi friends, Source: Whizlabs Final Exam What is your design observation on the following code fragment - I thought this was an example of Low Cohesion, but the right answer is Tight Coupling. Now,both sound right to me. Is there a reason why this isn't a good example of Low Cohesion? Thanks, Seema
|
 |
Lakuma Yalamanchili
Greenhorn
Joined: Sep 24, 2008
Posts: 26
|
|
Coupling can be identified by how much change in another class would bring a change to this class. It should be as less as possible. Tight Coupling is kind of a bad design as you know! The Truck class in the code has two other classes present in it which kind of makes it dependable on those classes and they are not even declared private! So tight coupling makes the right answer! Low cohesion is not the answer because, cohesion defines how specific is a class made to it's operation! If the class Truck performed the Driver and the Price class related operations it would have been low cohesion, but as seen in the code, Driver and Price have their own classes. Hope I could drive the point. Please let me know if this is not clear! And please do correct me if you feel I have messed up something! Regards, Lakuma
|
 |
Seema Gaurav
Ranch Hand
Joined: Apr 29, 2008
Posts: 47
|
|
Oh yes, Lakuma, you made it very clear. Looks like I was royally confused. You are right, the Truck class didn't have any of the Driver or Price classes behavior in it. I totally missed that point Thanks to you, my fundas are in place now Seema
|
 |
Lakuma Yalamanchili
Greenhorn
Joined: Sep 24, 2008
Posts: 26
|
|
Good to know I was able to help!! Good luck to you!!
|
 |
 |
|
|
subject: Low Cohesion or Tight Coupling?
|
|
|