aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Has-A relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Has-A relationship" Watch "Has-A relationship" New topic
Author

Has-A relationship

Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
can we say that has a relationship supports high cohesion as it allows a class to be more specialized.....and what about coupling? coupling means how much a class knows about the other or the Api stuff....having a has a relation doesnt mean that the class knows only about the api stuff....so i dont think we can say anything about that....but in good OO we will have loose coupling

and what about encapsulation? in good oo design again good encapsulation but about non oo design???




scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
How does has-a makes a class more specialised?

coupling means how much a class knows about the other or the Api stuff....having a has a relation doesnt mean that the class knows only about the api stuff....so i dont think we can say anything about that....but in good OO we will have loose coupling


thats correct.


SCJP 1.6 96%
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
hey neha....specialized is related to cohesion and not coupling.....you posted a coupling answer to cohesion
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
No, first one is my question and second one is answer to your question.
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
well since a class is using another class means that it is using the services of another class instead of implementing those servies itself....which means it only does specialized work whereas uses the work of anther class to do work which it cant do........i guess this what specializing means....

a manager uses two different people..one to look after the accounts and one to lok after the sales....with himself looking after the hrd department.......this is has a relationship with specializing
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
does making the methods private lead to loose coupling? the 2 minute drill of k&b says that loose coupling is the desirable state of having classes that are well encapsulated......how best is this true?

or coupling is only related to the amount api stuff one class knows about the other.....but others are trivial to this one?

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Raju Champaklal wrote:does making the methods private lead to loose coupling? the 2 minute drill of k&b says that loose coupling is the desirable state of having classes that are well encapsulated......how best is this true?




i can say above example is Loose Coupling

Raju Champaklal wrote:
can we say that has a relationship supports high cohesion as it allows a class to be more specialized.....and what about coupling?


Obviously, tight coupling
 
 
subject: Has-A relationship