• Post Reply Bookmark Topic Watch Topic
  • New Topic

Delegation?  RSS feed

 
kumar thokkala
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
Can someone explain what Delegation means in programming language context?
I did google, but couldn't find sites that really explains it in detail, so I am seeking your help.


Thanks
K.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In software engineering, the delegation pattern is a technique where an object outwardly expresses certain behaviour but in reality delegates responsibility for implementing that behavior to an associated object in an Inversion of Responsibility. This simulates mixins, delegation, and some kinds of aspects in traditional object-oriented languages like C++ and Java. Aggregation must be used with it if inheritance is not applicable.


Check here.
 
kumar thokkala
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the use of Delegation?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Part of it is Never Do Anything You Can Get Someone Else To Do. If you find a class doing three things, it should probably "delegate" two of those things to somebody else. (There are other ways to reallocate responsibilities to other classes, but this is the one you asked about.) One nice thing about delegates is that you can swap polymorphic delegates in and out. One day you might delegate logging to something that writes to disk, another day to something that writes to a database.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!