• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Delegation 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


I think that in Java the word delegation means it is HAS - A relationship .

and Delegation is equal to Composition or Aggregation .

Please correct me if i am wrong .

Please let me know what is meant by Delegation in java ??
 
Vijitha Kumara
Bartender
Posts: 3914
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is, you wrap a particular type of object and pass (delegate) method calls to the wrapped object, this is the fundamental for the Decorator pattern. And yes that's achieved through a HAS-A relationship.
 
Lee Kian Giap
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, You cannot say Delegation is equal to Composition or Aggregation.

As Vijitha Kumara said, Delegation is achieved using Composition/Aggregation.

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Delegation is achieved using Composition/Aggregation.


Thank you very much . This line explains .
 
Raj chiru
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use delegation when you want to use another class's functionality,as is, without changing that behavior at all.
In another words,if you need to use functionality in another class,but you don't want to change that functionality,consider using delegation instead of inheritance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic