Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Delegation pattern
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Design pattern in object-oriented programming}} In [[software engineering]], the '''delegation pattern''' is an [[object-oriented programming|object-oriented]] [[design pattern]] that allows [[object composition]] to achieve the same [[code reuse]] as [[inheritance (object-oriented programming)|inheritance]]. In delegation, an [[object (computer science)|object]] handles a request by delegating to a second object (the ''delegate''). The delegate is a [[helper object]], but ''with the original context''. With language-level support for delegation, this is done implicitly by having <code>[[self (computer science)|self]]</code> in the delegate refer to the original (sending) object, not the delegate (receiving object). In the delegate pattern, this is instead accomplished by explicitly passing the original object to the delegate, as an argument to a method.<ref>Gamma et al. 1994</ref> "Delegation" is often used loosely to refer to the distinct concept of [[forwarding (object-oriented programming)|forwarding]], where the sending object simply uses the corresponding member on the receiving object, evaluated in the context of the ''receiving'' object, not the original object. This article uses "sending object/receiving object" for the two objects, rather than "receiving object/delegate", emphasizing which objects send and receive the delegation call, not the original call.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)