<s>
In	O
object-oriented	B-Language
programming	I-Language
,	O
delegation	B-Application
refers	O
to	O
evaluating	O
a	O
member	O
(	O
property	B-Language
or	O
method	B-Language
)	O
of	O
one	O
object	O
(	O
the	O
receiver	O
)	O
in	O
the	O
context	O
of	O
another	O
original	O
object	O
(	O
the	O
sender	O
)	O
.	O
</s>
<s>
Delegation	B-Application
can	O
be	O
done	O
explicitly	O
,	O
by	O
passing	O
the	O
sending	O
object	O
to	O
the	O
receiving	O
object	O
,	O
which	O
can	O
be	O
done	O
in	O
any	O
object-oriented	B-Language
language	I-Language
;	O
or	O
implicitly	O
,	O
by	O
the	O
member	O
lookup	O
rules	O
of	O
the	O
language	O
,	O
which	O
requires	O
language	O
support	O
for	O
the	O
feature	O
.	O
</s>
<s>
Implicit	O
delegation	B-Application
is	O
the	O
fundamental	O
method	B-Language
for	O
behavior	O
reuse	O
in	O
prototype-based	B-Application
programming	I-Application
,	O
corresponding	O
to	O
inheritance	B-Language
in	O
class-based	B-Application
programming	I-Application
.	O
</s>
<s>
The	O
best-known	O
languages	O
that	O
support	O
delegation	B-Application
at	O
the	O
language	O
level	O
are	O
Self	B-Operating_System
,	O
which	O
incorporates	O
the	O
notion	O
of	O
delegation	B-Application
through	O
its	O
notion	O
of	O
mutable	B-Application
parent	O
slots	B-Architecture
that	O
are	O
used	O
upon	O
method	B-Language
lookup	O
on	O
self	B-Operating_System
calls	O
,	O
and	O
JavaScript	B-Language
;	O
see	O
JavaScript	B-Language
delegation	B-Application
.	O
</s>
<s>
The	O
term	O
delegation	B-Application
is	O
also	O
used	O
loosely	O
for	O
various	O
other	O
relationships	O
between	O
objects	O
;	O
see	O
delegation	B-Application
(	O
programming	O
)	O
for	O
more	O
.	O
</s>
<s>
Frequently	O
confused	O
concepts	O
are	O
simply	O
using	O
another	O
object	O
,	O
more	O
precisely	O
referred	O
to	O
as	O
consultation	O
or	O
aggregation	B-Language
;	O
and	O
evaluating	O
a	O
member	O
on	O
one	O
object	O
by	O
evaluating	O
the	O
corresponding	O
member	O
on	O
another	O
object	O
,	O
notably	O
in	O
the	O
context	O
of	O
the	O
receiving	O
object	O
,	O
which	O
is	O
more	O
precisely	O
referred	O
to	O
as	O
forwarding	B-Application
(	O
when	O
a	O
wrapper	O
object	O
does	O
n't	O
pass	O
itself	O
to	O
the	O
wrapped	O
object	O
)	O
.	O
</s>
<s>
The	O
delegation	B-Language
pattern	I-Language
is	O
a	O
software	O
design	O
pattern	O
for	O
implementing	O
delegation	B-Application
,	O
though	O
this	O
term	O
is	O
also	O
used	O
loosely	O
for	O
consultation	O
or	O
forwarding	B-Application
.	O
</s>
<s>
This	O
sense	O
of	O
delegation	B-Application
as	O
programming	O
language	O
feature	O
making	O
use	O
of	O
the	O
method	B-Language
lookup	O
rules	O
for	O
dispatching	O
so-called	O
self-calls	O
was	O
defined	O
by	O
Lieberman	O
in	O
his	O
1986	O
paper	O
"	O
Using	O
Prototypical	O
Objects	O
to	O
Implement	O
Shared	O
Behavior	O
in	O
Object-Oriented	B-Language
Systems	O
"	O
.	O
</s>
<s>
Delegation	B-Application
is	O
dependent	O
upon	O
dynamic	O
binding	O
,	O
as	O
it	O
requires	O
that	O
a	O
given	O
method	B-Language
call	I-Language
can	O
invoke	O
different	O
segments	O
of	O
code	O
at	O
runtime	O
.	O
</s>
<s>
It	O
is	O
used	O
throughout	O
macOS	B-Application
(	O
and	O
its	O
predecessor	O
NeXTStep	B-Application
)	O
as	O
a	O
means	O
of	O
customizing	O
the	O
behavior	O
of	O
program	O
components	O
.	O
</s>
<s>
Delegation	B-Application
can	O
be	O
characterized	O
(	O
and	O
distinguished	O
from	O
forwarding	B-Application
)	O
as	O
late	O
binding	O
of	O
self	B-Operating_System
:	O
</s>
<s>
That	O
is	O
,	O
the	O
in	O
a	O
method	B-Language
definition	O
in	O
the	O
receiving	O
object	O
is	O
not	O
statically	O
bound	O
to	O
that	O
object	O
at	O
definition	O
time	O
(	O
such	O
as	O
compile	O
time	O
or	O
when	O
the	O
function	O
is	O
attached	O
to	O
an	O
object	O
)	O
,	O
but	O
rather	O
at	O
evaluation	O
time	O
,	O
it	O
is	O
bound	O
to	O
the	O
original	O
object	O
.	O
</s>
<s>
It	O
has	O
been	O
argued	O
that	O
delegation	B-Application
may	O
in	O
some	O
cases	O
be	O
preferred	O
to	O
inheritance	B-Language
to	O
make	O
program	O
code	O
more	O
readable	O
and	O
understandable	O
.	O
</s>
<s>
Despite	O
explicit	O
delegation	B-Application
being	O
fairly	O
widespread	O
,	O
relatively	O
few	O
major	O
programming	O
languages	O
implement	O
delegation	B-Application
as	O
an	O
alternative	O
model	O
to	O
inheritance	B-Language
.	O
</s>
<s>
The	O
precise	O
relationship	O
between	O
delegation	B-Application
and	O
inheritance	B-Language
is	O
complicated	O
;	O
some	O
authors	O
consider	O
them	O
equivalent	O
,	O
or	O
one	O
a	O
special	O
case	O
of	O
the	O
other	O
.	O
</s>
<s>
In	O
languages	O
that	O
support	O
delegation	B-Application
via	O
method	B-Language
lookup	O
rules	O
,	O
method	B-Language
dispatching	O
is	O
defined	O
the	O
way	O
it	O
is	O
defined	O
for	O
virtual	O
methods	O
in	O
inheritance	B-Language
:	O
It	O
is	O
always	O
the	O
most	O
specific	O
method	B-Language
that	O
is	O
chosen	O
during	O
method	B-Language
lookup	O
.	O
</s>
<s>
Hence	O
it	O
is	O
the	O
original	O
receiver	O
entity	O
that	O
is	O
the	O
start	O
of	O
method	B-Language
lookup	O
even	O
though	O
it	O
has	O
passed	O
on	O
control	O
to	O
some	O
other	O
object	O
(	O
through	O
a	O
delegation	B-Application
link	O
,	O
not	O
an	O
object	O
reference	O
)	O
.	O
</s>
<s>
Delegation	B-Application
has	O
the	O
advantage	O
that	O
it	O
can	O
take	O
place	O
at	O
run	O
time	O
and	O
affect	O
only	O
a	O
subset	O
of	O
entities	O
of	O
some	O
type	O
and	O
can	O
even	O
be	O
removed	O
at	O
run	O
time	O
.	O
</s>
<s>
Inheritance	B-Language
,	O
by	O
contrast	O
,	O
typically	O
targets	O
the	O
type	O
rather	O
than	O
the	O
instances	O
,	O
and	O
is	O
restricted	O
to	O
compile	O
time	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
inheritance	B-Language
can	O
be	O
statically	O
type-checked	O
,	O
while	O
delegation	B-Application
generally	O
cannot	O
without	O
generics	O
(	O
although	O
a	O
restricted	O
version	O
of	O
delegation	B-Application
can	O
be	O
statically	O
typesafe	O
)	O
.	O
</s>
<s>
Delegation	B-Application
can	O
be	O
termed	O
"	O
run-time	O
inheritance	B-Language
for	O
specific	O
objects.	O
"	O
</s>
<s>
Here	O
is	O
a	O
pseudocode	B-Language
example	O
in	O
a	O
C#	B-Application
/Java	O
like	O
language	O
:	O
</s>
<s>
The	O
resulting	O
ambiguity	O
of	O
is	O
referred	O
to	O
as	O
object	B-Application
schizophrenia	I-Application
.	O
</s>
<s>
Translating	O
the	O
implicit	O
into	O
an	O
explicit	O
parameter	O
,	O
the	O
call	O
(	O
in	O
,	O
with	O
a	O
delegate	O
)	O
translates	O
to	O
,	O
using	O
the	O
type	O
of	O
for	O
method	B-Language
resolution	O
,	O
but	O
the	O
delegating	O
object	O
for	O
the	O
argument	O
.	O
</s>
<s>
Using	O
inheritance	B-Language
,	O
the	O
analogous	O
code	O
(	O
using	O
capital	O
letters	O
to	O
emphasize	O
that	O
resolution	O
is	O
based	O
on	O
classes	O
,	O
not	O
objects	O
)	O
is	O
:	O
</s>
<s>
In	O
this	O
case	O
,	O
is	O
unambiguous	O
:	O
there	O
is	O
a	O
single	O
object	O
,	O
,	O
and	O
resolves	O
to	O
the	O
method	B-Language
on	O
the	O
subclass	O
.	O
</s>
<s>
Programming	O
languages	O
in	O
general	O
do	O
not	O
support	O
this	O
unusual	O
form	O
of	O
delegation	B-Application
as	O
a	O
language	O
concept	O
,	O
but	O
there	O
are	O
a	O
few	O
exceptions	O
.	O
</s>
<s>
This	O
calls	O
for	O
additional	O
rules	O
for	O
method	B-Language
lookup	O
,	O
as	O
there	O
are	O
now	O
potentially	O
two	O
methods	O
that	O
can	O
be	O
denoted	O
as	O
the	O
most	O
specific	O
(	O
due	O
to	O
the	O
two	O
lookup	O
paths	O
)	O
.	O
</s>
<s>
Delegation	B-Application
can	O
be	O
described	O
as	O
a	O
low	O
level	O
mechanism	O
for	O
sharing	O
code	O
and	O
data	O
between	O
entities	O
.	O
</s>
<s>
Notably	O
role-oriented	B-General_Concept
programming	I-General_Concept
languages	O
have	O
been	O
utilizing	O
delegation	B-Application
,	O
but	O
especially	O
the	O
older	O
ones	O
factually	O
used	O
aggregation	B-Language
while	O
claiming	O
to	O
use	O
delegation	B-Application
.	O
</s>
<s>
This	O
should	O
not	O
be	O
considered	O
cheating	O
,	O
merely	O
the	O
plural	O
definitions	O
of	O
what	O
delegation	B-Application
means	O
(	O
as	O
described	O
above	O
)	O
.	O
</s>
<s>
More	O
recently	O
work	O
has	O
also	O
been	O
done	O
on	O
distributing	O
delegation	B-Application
,	O
so	O
e.g.	O
</s>
<s>
clients	O
of	O
a	O
search	O
engine	O
(	O
finding	O
cheap	O
hotel	O
rooms	O
)	O
can	O
use	O
a	O
shared	O
entity	O
using	O
delegation	B-Application
to	O
share	O
best	O
hits	O
and	O
general	O
re-usable	O
functionality	O
.	O
</s>
<s>
Delegation	B-Application
has	O
also	O
been	O
suggested	O
for	O
advice	O
resolution	O
in	O
aspect-oriented	B-Architecture
programming	I-Architecture
by	O
Ernst	O
and	O
Lorenz	O
in	O
2003	O
.	O
</s>
