Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Has-A relationship

 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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???



 
Neha Daga
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey neha....specialized is related to cohesion and not coupling.....you posted a coupling answer to cohesion
 
Neha Daga
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, first one is my question and second one is answer to your question.
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic