<s>
Data	B-Architecture
,	I-Architecture
context	I-Architecture
,	I-Architecture
and	I-Architecture
interaction	I-Architecture
(	O
DCI	O
)	O
is	O
a	O
paradigm	O
used	O
in	O
computer	O
software	O
to	O
program	O
systems	O
of	O
communicating	O
objects	O
.	O
</s>
<s>
To	O
improve	O
the	O
readability	O
of	O
object-oriented	B-Language
code	I-Language
by	O
giving	O
system	O
behavior	O
first-class	O
status	O
;	O
</s>
<s>
To	O
support	O
an	O
object	O
style	O
of	O
thinking	O
that	O
is	O
close	O
to	O
programmers	O
 '	O
mental	O
models	O
,	O
rather	O
than	O
the	O
class	O
style	O
of	O
thinking	O
that	O
overshadowed	O
object	O
thinking	O
early	O
in	O
the	O
history	O
of	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
The	O
paradigm	O
separates	O
the	O
domain	B-Application
model	I-Application
(	O
data	O
)	O
from	O
use	B-Architecture
cases	I-Architecture
(	O
context	O
)	O
and	O
Roles	B-General_Concept
that	O
objects	O
play	O
(	O
interaction	O
)	O
.	O
</s>
<s>
These	O
classes	O
are	O
barely	O
smart	O
data	O
,	O
and	O
they	O
explicitly	O
lack	O
the	O
functionality	O
that	O
is	O
peculiar	O
to	O
support	O
of	O
any	O
particular	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
The	O
context	O
is	O
the	O
class	O
(	O
or	O
its	O
instance	O
)	O
whose	O
code	O
includes	O
the	O
Roles	B-General_Concept
for	O
a	O
given	O
algorithm	O
,	O
scenario	O
,	O
or	O
use	B-Architecture
case	I-Architecture
,	O
as	O
well	O
as	O
the	O
code	O
to	O
map	O
these	O
Roles	B-General_Concept
into	O
objects	O
at	O
run	O
time	O
and	O
to	O
enact	O
the	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
Each	O
Role	B-General_Concept
is	O
bound	O
to	O
exactly	O
one	O
object	O
during	O
any	O
given	O
use	B-Architecture
case	I-Architecture
enactment	O
;	O
however	O
,	O
a	O
single	O
object	O
may	O
simultaneously	O
play	O
several	O
Roles	B-General_Concept
.	O
</s>
<s>
A	O
context	O
is	O
instantiated	O
at	O
the	O
beginning	O
of	O
the	O
enactment	O
of	O
an	O
algorithm	O
,	O
scenario	O
,	O
or	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
In	O
summary	O
,	O
a	O
context	O
comprises	O
use	B-Architecture
cases	I-Architecture
and	O
algorithms	O
in	O
which	O
data	O
objects	O
are	O
used	O
through	O
specific	O
Roles	B-General_Concept
.	O
</s>
<s>
Each	O
context	O
represents	O
one	O
or	O
more	O
use	B-Architecture
cases	I-Architecture
.	O
</s>
<s>
A	O
context	O
object	O
is	O
instantiated	O
for	O
each	O
enactment	O
of	O
a	O
use	B-Architecture
case	I-Architecture
for	O
which	O
it	O
is	O
responsible	O
.	O
</s>
<s>
Its	O
main	O
job	O
is	O
to	O
identify	O
the	O
objects	O
that	O
will	O
participate	O
in	O
the	O
use	B-Architecture
case	I-Architecture
and	O
to	O
assign	O
them	O
to	O
play	O
the	O
Roles	B-General_Concept
which	O
carry	O
out	O
the	O
use	B-Architecture
case	I-Architecture
through	O
their	O
responsibilities	O
.	O
</s>
<s>
A	O
Role	B-General_Concept
may	O
comprise	O
methods	O
,	O
and	O
each	O
method	O
is	O
some	O
small	O
part	O
of	O
the	O
logic	O
of	O
an	O
algorithm	O
implementing	O
a	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
Role	B-General_Concept
methods	O
run	O
in	O
the	O
context	O
of	O
an	O
object	O
that	O
is	O
selected	O
by	O
the	O
context	O
to	O
play	O
that	O
Role	B-General_Concept
for	O
the	O
current	O
use	B-Architecture
case	I-Architecture
enactment	O
.	O
</s>
<s>
The	O
Role-to-object	O
bindings	O
that	O
take	O
place	O
in	O
a	O
context	O
can	O
be	O
contrasted	O
with	O
the	O
polymorphism	O
of	O
vernacular	O
object-oriented	B-Language
programming	I-Language
.	O
</s>
<s>
The	O
overall	O
business	O
functionality	O
is	O
the	O
sum	O
of	O
complex	O
,	O
dynamic	O
networks	O
of	O
methods	O
decentralized	O
in	O
multiple	O
contexts	O
and	O
their	O
Roles	B-General_Concept
.	O
</s>
<s>
Each	O
context	O
is	O
a	O
scope	O
that	O
includes	O
identifiers	O
that	O
correspond	O
to	O
its	O
Roles	B-General_Concept
.	O
</s>
<s>
Any	O
Role	B-General_Concept
executing	O
within	O
that	O
context	O
can	O
refer	O
to	O
the	O
other	O
Roles	B-General_Concept
in	O
that	O
context	O
through	O
these	O
identifiers	O
.	O
</s>
<s>
At	O
use	B-Architecture
case	I-Architecture
enactment	O
time	O
,	O
each	O
and	O
every	O
one	O
of	O
these	O
identifiers	O
becomes	O
bound	O
to	O
an	O
object	O
playing	O
the	O
corresponding	O
Role	B-General_Concept
for	O
this	O
context	O
.	O
</s>
<s>
An	O
example	O
of	O
a	O
context	O
could	O
be	O
a	O
wire	O
transfer	O
between	O
two	O
accounts	O
,	O
where	O
data	O
models	O
(	O
the	O
banking	O
accounts	O
)	O
are	O
used	O
through	O
Roles	B-General_Concept
named	O
SourceAccount	O
and	O
DestinationAccount	O
.	O
</s>
<s>
The	O
interaction	O
is	O
implemented	O
as	O
Roles	B-General_Concept
which	O
are	O
played	O
by	O
objects	O
at	O
run	O
time	O
.	O
</s>
<s>
These	O
objects	O
combine	O
the	O
state	O
and	O
methods	O
of	O
a	O
data	O
(	O
domain	O
)	O
object	O
with	O
methods	O
(	O
but	O
no	O
state	O
,	O
as	O
Roles	B-General_Concept
are	O
stateless	O
)	O
from	O
one	O
or	O
more	O
Roles	B-General_Concept
.	O
</s>
<s>
In	O
good	O
DCI	O
style	O
,	O
a	O
Role	B-General_Concept
addresses	O
another	O
object	O
only	O
in	O
terms	O
of	O
its	O
(	O
methodless	O
)	O
Role	B-General_Concept
.	O
</s>
<s>
There	O
is	O
a	O
special	O
Role	B-General_Concept
called	O
self	B-Operating_System
which	O
binds	O
to	O
the	O
object	O
playing	O
the	O
current	O
Role	B-General_Concept
.	O
</s>
<s>
Code	O
within	O
a	O
Role	B-General_Concept
method	O
may	O
invoke	O
a	O
method	O
on	O
self	B-Operating_System
and	O
thereby	O
invoke	O
a	O
method	O
of	O
the	O
data	O
part	O
of	O
the	O
current	O
object	O
.	O
</s>
<s>
One	O
curious	O
aspect	O
of	O
DCI	O
is	O
that	O
these	O
bindings	O
are	O
guaranteed	O
to	O
be	O
in	O
place	O
only	O
at	O
run	O
time	O
(	O
using	O
a	O
variety	O
of	O
approaches	O
and	O
conventions	O
;	O
C++	B-Application
templates	I-Application
can	O
be	O
used	O
to	O
guarantee	O
that	O
the	O
bindings	O
will	O
succeed	O
)	O
.	O
</s>
<s>
This	O
means	O
that	O
interactions	O
,	O
the	O
Role	B-General_Concept
methods	O
,	O
are	O
generic	O
.	O
</s>
<s>
In	O
fact	O
,	O
some	O
DCI	O
implementations	O
use	O
generics	O
or	O
templates	B-Application
for	O
Roles	B-General_Concept
.	O
</s>
<s>
A	O
Role	B-General_Concept
is	O
a	O
stateless	O
programming	O
construct	O
that	O
corresponds	O
to	O
the	O
end	O
user	O
's	O
mental	O
model	O
of	O
some	O
entity	O
in	O
the	O
system	O
.	O
</s>
<s>
A	O
Role	B-General_Concept
represents	O
a	O
collection	O
of	O
responsibilities	O
.	O
</s>
<s>
Whereas	O
vernacular	O
object-oriented	B-Language
programming	I-Language
speaks	O
of	O
objects	O
or	O
classes	O
as	O
a	O
multiplicity	O
of	O
responsibilities	O
,	O
DCI	O
ascribes	O
them	O
to	O
Roles	B-General_Concept
.	O
</s>
<s>
An	O
object	O
participating	O
in	O
a	O
use	B-Architecture
case	I-Architecture
has	O
responsibilities	O
:	O
those	O
that	O
it	O
takes	O
on	O
as	O
a	O
result	O
of	O
playing	O
a	O
particular	O
Role	B-General_Concept
.	O
</s>
<s>
Most	O
modern	O
programming	O
languages	O
have	O
a	O
way	O
to	O
express	O
Roles	B-General_Concept
,	O
and	O
to	O
express	O
the	O
injection	O
of	O
Role	B-General_Concept
methods	O
into	O
objects	O
,	O
and	O
implementation	O
techniques	O
vary	O
depending	O
on	O
the	O
language	O
.	O
</s>
<s>
The	O
injection	O
can	O
be	O
fully	O
dynamic	O
at	O
run-time	O
in	O
languages	O
like	O
Ruby	B-Language
and	O
Python	B-Language
;	O
it	O
is	O
more	O
static	O
in	O
languages	O
like	O
Smalltalk-Squeak	O
,	O
Scala	B-Application
and	O
C++	B-Language
.	O
</s>
<s>
The	O
Qi4j	O
programming	O
environment	O
offers	O
a	O
way	O
to	O
express	O
Role	B-General_Concept
method	O
injection	O
into	O
Java	B-Language
objects	O
.	O
</s>
<s>
Java	B-Language
8	O
on	O
interfaces	O
can	O
be	O
used	O
to	O
implement	O
Roles	B-General_Concept
in	O
a	O
typesafe	O
way	O
.	O
</s>
<s>
In	O
the	O
above	O
money	O
transfer	O
use	B-Architecture
case	I-Architecture
,	O
for	O
example	O
,	O
the	O
Role	B-General_Concept
methods	O
in	O
the	O
SourceAccount	O
and	O
DestinationAccount	O
enact	O
the	O
actual	O
transfer	O
.	O
</s>
<s>
DCI	O
limits	O
all	O
permissible	O
networks	O
of	O
communicating	O
objects	O
to	O
networks	O
that	O
share	O
common	O
topologies	O
,	O
one	O
for	O
each	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
Such	O
networks	O
are	O
explicit	O
in	O
the	O
interactions	O
between	O
DCI	O
Roles	B-General_Concept
,	O
whereas	O
in	O
classical	O
object	O
orientation	O
they	O
are	O
emergent	O
.	O
</s>
<s>
A	O
Role	B-General_Concept
is	O
a	O
node	O
in	O
such	O
a	O
topology	O
;	O
it	O
is	O
a	O
partial	O
classification	O
of	O
the	O
behaviors	O
of	O
all	O
objects	O
that	O
can	O
occupy	O
this	O
node	O
.	O
</s>
<s>
An	O
object-oriented	B-Language
program	O
is	O
a	O
complex	O
and	O
dynamic	O
network	O
of	O
objects	O
,	O
in	O
the	O
same	O
sense	O
that	O
relationships	O
between	O
real-world	O
objects	O
are	O
complex	O
and	O
dynamic	O
.	O
</s>
<s>
In	O
DCI	O
these	O
different	O
views	O
are	O
factored	O
into	O
Roles	B-General_Concept
.	O
</s>
<s>
At	O
run	O
time	O
,	O
the	O
Role	B-General_Concept
is	O
the	O
identity	O
of	O
the	O
object	O
.	O
</s>
<s>
During	O
the	O
enactment	O
of	O
a	O
use	B-Architecture
case	I-Architecture
(	O
like	O
Serve	O
the	O
Wine	O
)	O
the	O
Role	B-General_Concept
Waiter	O
unambiguously	O
identifies	O
a	O
single	O
object	O
at	O
any	O
given	O
time	O
.	O
</s>
<s>
However	O
,	O
they	O
are	O
likely	O
to	O
differ	O
in	O
their	O
responsibilities	O
within	O
a	O
use	B-Architecture
case	I-Architecture
,	O
such	O
as	O
are	O
found	O
in	O
Role	B-General_Concept
names	O
HeadWaiter	O
and	O
Busboy	O
.	O
</s>
<s>
So	O
a	O
Role	B-General_Concept
like	O
HeadWaiter	O
becomes	O
the	O
identifier	O
,	O
the	O
handle	O
,	O
by	O
which	O
objects	O
refer	O
to	O
each	O
other	O
in	O
a	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
The	O
object	O
has	O
its	O
own	O
identity	O
independent	O
of	O
the	O
use	B-Architecture
case	I-Architecture
;	O
this	O
is	O
the	O
Data	O
facet	O
of	O
DCI	O
.	O
</s>
<s>
Roles	B-General_Concept
are	O
aliased	O
names	O
for	O
their	O
objects	O
but	O
are	O
never	O
separate	O
objects	O
themselves	O
;	O
that	O
would	O
cause	O
self	B-Application
schizophrenia	I-Application
.	O
</s>
<s>
The	O
object	O
has	O
many	O
possible	O
identities	O
depending	O
on	O
the	O
use	B-Architecture
case	I-Architecture
it	O
is	O
involved	O
in	O
;	O
this	O
surfaces	O
in	O
the	O
Role	B-General_Concept
identities	O
that	O
form	O
part	O
of	O
the	O
Interaction	O
facet	O
of	O
DCI	O
.	O
</s>
<s>
The	O
code	O
is	O
dominated	O
by	O
the	O
use	B-Architecture
case	I-Architecture
structure	O
,	O
which	O
cuts	O
across	O
the	O
objects	O
,	O
and	O
which	O
also	O
is	O
part	O
of	O
the	O
Interaction	O
facet	O
of	O
DCI	O
.	O
</s>
<s>
DCI	O
allows	O
an	O
object	O
to	O
take	O
on	O
one	O
or	O
more	O
Roles	B-General_Concept
during	O
a	O
use	B-Architecture
case	I-Architecture
enactment	O
.	O
</s>
<s>
In	O
other	O
words	O
,	O
an	O
object	O
is	O
re-bound	O
to	O
Role	B-General_Concept
identifiers	O
on	O
each	O
use	B-Architecture
case	I-Architecture
enactment	O
.	O
</s>
<s>
These	O
Roles	B-General_Concept
infer	O
an	O
interface	O
,	O
referred	O
to	O
as	O
the	O
Role	B-General_Concept
type	O
.	O
</s>
<s>
Each	O
object	O
is	O
"	O
re-cast	O
"	O
(	O
in	O
the	O
theatrical	O
sense	O
)	O
anew	O
on	O
every	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
Though	O
a	O
Role	B-General_Concept
is	O
bound	O
only	O
to	O
a	O
single	O
object	O
,	O
an	O
object	O
may	O
play	O
several	O
Roles	B-General_Concept
.	O
</s>
<s>
For	O
example	O
,	O
a	O
HeadWaiter	O
may	O
be	O
involved	O
in	O
a	O
use	B-Architecture
case	I-Architecture
to	O
count	O
all	O
the	O
occupants	O
of	O
the	O
restaurant	O
during	O
a	O
fire	O
inspection	O
,	O
and	O
will	O
play	O
the	O
Person	O
Role	B-General_Concept
as	O
well	O
as	O
the	O
HeadWaiter	O
Role	B-General_Concept
.	O
</s>
<s>
The	O
single	O
object	O
supports	O
the	O
behaviors	O
of	O
both	O
Roles	B-General_Concept
necessary	O
to	O
carry	O
out	O
the	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
Objects	O
dynamically	O
take	O
on	O
Roles	B-General_Concept
during	O
use	B-Architecture
case	I-Architecture
enactments	O
;	O
</s>
<s>
Every	O
Role	B-General_Concept
of	O
a	O
use	B-Architecture
case	I-Architecture
is	O
played	O
by	O
an	O
object	O
determined	O
by	O
the	O
Context	O
at	O
the	O
start	O
of	O
the	O
use	B-Architecture
case	I-Architecture
enactment	O
;	O
</s>
<s>
The	O
network	O
of	O
Interactions	O
between	O
Roles	B-General_Concept
in	O
the	O
code	O
(	O
i.e.	O
,	O
at	O
coding	O
time	O
)	O
is	O
the	O
same	O
as	O
the	O
corresponding	O
network	O
of	O
objects	O
at	O
run	O
time	O
;	O
</s>
<s>
These	O
networks	O
are	O
potentially	O
re-created	O
on	O
every	O
use	B-Architecture
case	I-Architecture
enactment	O
;	O
</s>
<s>
Roles	B-General_Concept
come	O
in	O
and	O
out	O
of	O
scope	O
with	O
use	B-Architecture
case	I-Architecture
lifetimes	O
,	O
but	O
objects	O
that	O
may	O
play	O
these	O
Roles	B-General_Concept
may	O
persist	O
across	O
multiple	O
use	B-Architecture
case	I-Architecture
lifetimes	O
and	O
may	O
potentially	O
play	O
many	O
Roles	B-General_Concept
over	O
their	O
own	O
lifetime	O
.	O
</s>
<s>
DCI	O
can	O
be	O
thought	O
of	O
as	O
an	O
event-driven	B-Application
programming	I-Application
paradigm	O
,	O
where	O
some	O
event	O
(	O
as	O
a	O
human	O
gesture	O
in	O
a	O
model-view-controller	O
(	O
MVC	O
)	O
architecture	O
)	O
triggers	O
a	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
The	O
use	B-Architecture
case	I-Architecture
can	O
be	O
short-lived	O
or	O
long-lived	O
.	O
</s>
<s>
The	O
type	O
of	O
object	O
is	O
chosen	O
according	O
to	O
the	O
kind	O
of	O
use	B-Architecture
case	I-Architecture
that	O
will	O
ensue	O
,	O
based	O
on	O
information	O
about	O
the	O
trigger	O
or	O
the	O
system	O
state	O
or	O
both	O
.	O
</s>
<s>
Once	O
the	O
environment	O
instantiates	O
the	O
Context	O
object	O
,	O
it	O
invokes	O
its	O
trigger	O
method	O
to	O
start	O
the	O
use	B-Architecture
case	I-Architecture
enactment	O
.	O
</s>
<s>
As	O
described	O
above	O
,	O
each	O
Context	O
provides	O
a	O
design	O
scope	O
for	O
the	O
Roles	B-General_Concept
that	O
participate	O
in	O
the	O
use	B-Architecture
case	I-Architecture
enactment	O
.	O
</s>
<s>
It	O
is	O
the	O
job	O
of	O
the	O
Context	O
to	O
assign	O
objects	O
to	O
play	O
these	O
Roles	B-General_Concept
.	O
</s>
<s>
The	O
Context	O
first	O
finds	O
the	O
objects	O
that	O
are	O
to	O
take	O
part	O
in	O
this	O
use	B-Architecture
case	I-Architecture
enactment	O
.	O
</s>
<s>
Within	O
a	O
Context	O
there	O
is	O
at	O
most	O
one	O
instance	O
playing	O
any	O
given	O
Role	B-General_Concept
at	O
any	O
given	O
time	O
.	O
</s>
<s>
Second	O
,	O
the	O
Context	O
assigns	O
a	O
single	O
object	O
to	O
play	O
each	O
of	O
its	O
Roles	B-General_Concept
(	O
though	O
a	O
single	O
object	O
often	O
plays	O
multiple	O
Roles	B-General_Concept
in	O
a	O
single	O
Context	O
)	O
.	O
</s>
<s>
In	O
strongly	O
dynamic	O
languages	O
(	O
Ruby	B-Language
,	O
Python	B-Language
)	O
the	O
Context	O
injects	O
the	O
Role	B-General_Concept
methods	O
into	O
the	O
object	O
.	O
</s>
<s>
In	O
most	O
dynamic	O
languages	O
,	O
any	O
extant	O
object	O
can	O
be	O
asked	O
to	O
play	O
any	O
Role	B-General_Concept
at	O
any	O
time	O
(	O
though	O
some	O
object-Role	O
combinations	O
may	O
of	O
course	O
make	O
no	O
sense	O
;	O
nonsense	O
combinations	O
of	O
objects	O
and	O
Roles	B-General_Concept
would	O
lead	O
to	O
MESSAGE	O
NOT	O
UNDERSTOOD	O
at	O
run	O
time	O
if	O
the	O
Role	B-General_Concept
method	O
were	O
invoked	O
.	O
)	O
</s>
<s>
In	O
more	O
statically	O
typed	O
languages	O
(	O
Scala	B-Application
,	O
C++	B-Language
)	O
there	O
has	O
to	O
have	O
been	O
some	O
prior	O
arrangement	O
for	O
the	O
object	O
to	O
support	O
the	O
Role	B-General_Concept
methods	O
.	O
</s>
<s>
For	O
example	O
,	O
Scala	B-Application
creates	O
an	O
anonymous	O
class	O
that	O
combines	O
the	O
rudimentary	O
logic	O
of	O
a	O
domain	O
class	O
with	O
the	O
use	B-Architecture
case	I-Architecture
logic	O
of	O
the	O
trait	O
used	O
to	O
implement	O
a	O
Role	B-General_Concept
;	O
Roles	B-General_Concept
are	O
effectively	O
assigned	O
to	O
domain	O
objects	O
when	O
they	O
are	O
instantiated	O
.	O
</s>
<s>
Third	O
,	O
the	O
Context	O
invokes	O
a	O
Role	B-General_Concept
method	O
on	O
the	O
first	O
object	O
to	O
take	O
part	O
in	O
the	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
From	O
that	O
point	O
forward	O
,	O
Roles	B-General_Concept
invoke	O
each	O
other	O
's	O
methods	O
to	O
carry	O
out	O
the	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
A	O
Role	B-General_Concept
method	O
may	O
invoke	O
a	O
method	O
on	O
self	B-Operating_System
which	O
in	O
fact	O
is	O
handled	O
by	O
the	O
object	O
currently	O
playing	O
the	O
Role	B-General_Concept
.	O
</s>
<s>
This	O
is	O
how	O
Roles	B-General_Concept
invoke	O
the	O
rudimentary	O
data	O
operations	O
of	O
the	O
objects	O
currently	O
playing	O
them	O
at	O
the	O
time	O
.	O
</s>
<s>
DCI	O
depends	O
on	O
a	O
design	O
process	O
that	O
separates	O
use	B-Architecture
cases	I-Architecture
from	O
the	O
data	O
model	O
.	O
</s>
<s>
The	O
Roles	B-General_Concept
that	O
characterize	O
the	O
end-user	O
'	O
s	O
model	O
of	O
system	O
functionality	O
come	O
from	O
the	O
use	B-Architecture
cases	I-Architecture
.	O
</s>
<s>
What	O
is	O
common	O
to	O
many	O
approaches	O
is	O
that	O
Roles	B-General_Concept
are	O
represented	O
by	O
such	O
constructs	O
as	O
generics	O
,	O
templates	B-Application
,	O
classes	O
,	O
or	O
traits	O
.	O
</s>
<s>
Code	O
for	O
the	O
basic	O
domain	O
logic	O
is	O
implemented	O
separately	O
,	O
following	O
conventional	O
object-oriented	B-Language
practice	O
and	O
most	O
commonly	O
using	O
classes	O
.	O
</s>
<s>
Each	O
Role	B-General_Concept
's	O
code	O
is	O
injected	O
into	O
the	O
domain	O
object	O
that	O
will	O
play	O
it	O
during	O
the	O
use	B-Architecture
case	I-Architecture
enactment	O
.	O
</s>
<s>
To	O
implement	O
Roles	B-General_Concept
,	O
method	O
injection	O
is	O
usually	O
needed	O
.	O
</s>
<s>
Some	O
languages	O
,	O
such	O
as	O
Scala	B-Application
,	O
have	O
native	O
support	O
for	O
traits	O
,	O
while	O
other	O
languages	O
(	O
e.g.	O
,	O
Ruby	B-Language
and	O
Python	B-Language
)	O
allow	O
run	O
time	O
injection	O
of	O
methods	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
pre-compiler	O
tricks	O
based	O
on	O
annotations	O
are	O
needed	O
to	O
support	O
DCI	O
.	O
</s>
<s>
Haxe	B-Language
uses	O
its	O
compile-time	O
macro	O
feature	O
to	O
transform	O
the	O
DCI	O
semantics	O
to	O
target	O
language	O
code	O
.	O
</s>
<s>
DCI	O
arose	O
largely	O
as	O
an	O
outgrowth	O
of	O
Trygve	O
Reenskaug	O
's	O
work	O
on	O
role-based	O
modeling	O
.	O
</s>
<s>
Trygve	O
had	O
long	O
recognized	O
that	O
Roles	B-General_Concept
played	O
a	O
central	O
part	O
in	O
the	O
way	O
programmers	O
think	O
about	O
objects	O
,	O
and	O
that	O
the	O
class-based	O
progression	O
of	O
programming	O
language	O
technology	O
took	O
away	O
much	O
of	O
the	O
motivation	O
to	O
think	O
about	O
the	O
objects	O
in	O
a	O
program	O
.	O
</s>
<s>
Further	O
,	O
the	O
fact	O
that	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
offered	O
only	O
classes	O
to	O
express	O
program	O
logic	O
left	O
the	O
programmer	O
at	O
the	O
mercy	O
of	O
the	O
structural	O
layout	O
of	O
the	O
data	O
to	O
delineate	O
behavior	O
,	O
which	O
is	O
unnatural	O
compared	O
with	O
a	O
delineating	O
behavior	O
on	O
Role	B-General_Concept
boundaries	O
.	O
</s>
<s>
This	O
in	O
turn	O
made	O
program	O
behavior	O
more	O
difficult	O
to	O
reason	O
about	O
than	O
in	O
,	O
say	O
,	O
a	O
procedural	O
program	O
in	O
Fortran	B-Application
.	O
</s>
<s>
He	O
prototyped	O
the	O
ideas	O
in	O
the	O
Baby	O
programming	O
environment	O
,	O
written	O
in	O
Squeak	B-Operating_System
.	O
</s>
<s>
James	O
Coplien	O
joined	O
Trygve	O
on	O
this	O
effort	O
in	O
about	O
2007	O
and	O
by	O
mid-2008	O
had	O
a	O
prototype	O
running	O
in	O
C++	B-Language
.	O
</s>
<s>
Steen	O
Lehmann	O
,	O
Rickard	O
Öberg	O
and	O
Niclas	O
Hedhman	O
accelerated	O
adaptating	O
these	O
ideas	O
to	O
Ruby	B-Language
and	O
Java	B-Language
over	O
the	O
next	O
year	O
or	O
so	O
with	O
the	O
Qi4j	O
framework	O
.	O
</s>
<s>
Most	O
of	O
the	O
previous	O
implementations	O
altered	O
the	O
role	B-General_Concept
player	O
objects	O
in	O
a	O
way	O
that	O
would	O
be	O
visible	O
outside	O
of	O
the	O
context	O
.	O
</s>
<s>
Different	O
approaches	O
taken	O
for	O
the	O
evolution	O
of	O
object-oriented	B-Language
programming	I-Language
,	O
both	O
on	O
a	O
language	O
and	O
pattern	O
level	O
,	O
agree	O
to	O
various	O
degrees	O
with	O
DCI	O
:	O
</s>
<s>
Mixins	B-Language
are	O
a	O
way	O
of	O
encapsulating	O
code	O
for	O
specific	O
what-the-system-does	O
functionality	O
in	O
closed	O
form	O
;	O
however	O
,	O
there	O
is	O
no	O
consistent	O
mechanism	O
to	O
link	O
multiple	O
mixins	B-Language
into	O
a	O
unit	O
at	O
the	O
level	O
of	O
a	O
use	B-Architecture
case	I-Architecture
.	O
</s>
<s>
They	O
can	O
be	O
employed	O
to	O
implement	O
to	O
the	O
concept	O
of	O
Role	B-General_Concept
in	O
DCI	O
,	O
although	O
not	O
in	O
a	O
strict	O
sense	O
.	O
</s>
<s>
True	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
like	O
Self	B-Operating_System
attempt	O
to	O
break	O
down	O
the	O
dichotomy	O
between	O
the	O
domains	O
of	O
classful	O
programming	O
and	O
objectful	O
execution	O
,	O
which	O
helps	O
programmers	O
focus	O
on	O
run-time	O
objects	O
.	O
</s>
<s>
DCI	O
restores	O
the	O
code-level	O
knowledge	O
about	O
the	O
relationships	O
between	O
them	O
in	O
Contexts	O
and	O
in	O
the	O
static	O
relationships	O
between	O
Role	B-General_Concept
methods	O
.	O
</s>
<s>
Dependency	B-Library
injection	I-Library
is	O
a	O
longstanding	O
approach	O
to	O
change	O
the	O
functionality	O
of	O
an	O
object	O
at	O
run	O
time	O
by	O
allowing	O
it	O
to	O
"	O
outsource	O
"	O
some	O
of	O
its	O
execution	O
to	O
an	O
external	O
object	O
that	O
can	O
be	O
re-bound	O
at	O
will	O
.	O
</s>
<s>
Most	O
implementations	O
of	O
dependency	B-Library
injection	I-Library
lead	O
to	O
the	O
self	B-Application
schizophrenia	I-Application
problem	O
,	O
which	O
implementations	O
of	O
DCI	O
address	O
properly	O
.	O
</s>
<s>
Multi-paradigm	O
design	O
attempts	O
to	O
separate	O
behavior	O
and	O
structure	O
by	O
according	O
the	O
behavior	O
to	O
a	O
procedural	O
design	O
and	O
the	O
structural	O
component	O
to	O
objects	O
,	O
allowing	O
free	O
access	O
between	O
them	O
,	O
in	O
accord	O
with	O
the	O
design	O
principles	O
of	O
C++	B-Language
.	O
</s>
<s>
The	O
challenges	O
of	O
object-oriented	B-Language
programming	I-Language
can	O
also	O
be	O
met	O
by	O
addressing	O
its	O
issues	O
on	O
the	O
paradigm	O
level	O
.	O
</s>
<s>
Aspect-oriented	B-Architecture
programming	I-Architecture
(	O
AOP	O
)	O
is	O
perhaps	O
the	O
closest	O
historic	O
relative	O
to	O
DCI	O
.	O
</s>
<s>
Most	O
use	O
of	O
Aspects	O
is	O
closely	O
tied	O
to	O
the	O
programmer	O
perspective	O
and	O
require	O
strong	O
tool	O
support	O
to	O
provide	O
good	O
understanding	O
of	O
the	O
software	O
's	O
behavivour	O
on	O
any	O
given	O
pointcut	B-Application
.	O
</s>
<s>
In	O
AOP	O
,	O
the	O
pointcut	B-Application
and	O
advice	B-Application
carry	O
equal	O
importance	O
and	O
though	O
physically	O
disjoint	O
,	O
must	O
be	O
understood	O
together	O
to	O
understand	O
the	O
code	O
,	O
because	O
the	O
advice	B-Application
is	O
invasive	O
at	O
the	O
pointcut	B-Application
.	O
</s>
<s>
DCI	O
can	O
be	O
thought	O
of	O
as	O
a	O
way	O
of	O
taking	O
a	O
large	O
advice	B-Application
and	O
allowing	O
parts	O
of	O
it	O
to	O
be	O
injected	O
into	O
a	O
number	O
of	O
regularized	O
pointcuts	B-Application
.	O
</s>
<s>
Role-oriented	B-General_Concept
programming	I-General_Concept
brings	O
together	O
ideas	O
from	O
Aspect-oriented	B-Architecture
programming	I-Architecture
,	O
conceptual	O
modeling	O
and	O
more	O
.	O
</s>
<s>
Early	O
attempts	O
(	O
1991	O
)	O
defined	O
roles	B-General_Concept
in	O
an	O
independent	O
fashion	O
,	O
but	O
more	O
recent	O
approaches	O
(	O
2002	O
and	O
onward	O
)	O
converge	O
in	O
emphasizing	O
that	O
roles	B-General_Concept
depend	O
on	O
context	O
(	O
also	O
"	O
teams	O
"	O
or	O
"	O
institutions	O
"	O
)	O
.	O
</s>
<s>
In	O
role-oriented	B-General_Concept
programming	I-General_Concept
,	O
roles	B-General_Concept
are	O
defined	O
with	O
respect	O
to	O
some	O
intrinsic	O
(	O
or	O
base	O
)	O
entity	O
,	O
which	O
corresponds	O
to	O
the	O
data-role	O
dichotomy	O
in	O
DCI	O
.	O
</s>
<s>
Both	O
approaches	O
emphasize	O
the	O
interaction	O
among	O
a	O
group	O
of	O
roles	B-General_Concept
.	O
</s>
<s>
Role-oriented	B-General_Concept
programming	I-General_Concept
is	O
focused	O
on	O
adding	O
support	O
for	O
roles	B-General_Concept
to	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
where	O
emphasis	O
is	O
on	O
increasing	O
the	O
expressiveness	O
of	O
a	O
programming	O
language	O
and	O
enabling	O
more	O
designs	O
.	O
</s>
<s>
"	O
within	O
DCI	O
you	O
do	O
not	O
inherit	O
roles	B-General_Concept
"	O
)	O
whereas	O
role-oriented	B-General_Concept
programming	I-General_Concept
embraces	O
(	O
and	O
even	O
enhances	O
)	O
inheritance	O
as	O
a	O
central	O
concept	O
of	O
object-orientated	B-Language
programming	I-Language
,	O
supporting	O
free	O
combination	O
with	O
other	O
concepts	O
.	O
</s>
<s>
DCI	O
emphasises	O
that	O
self	B-Application
schizophrenia	I-Application
should	O
be	O
avoided	O
,	O
whereas	O
role-oriented	B-General_Concept
programming	I-General_Concept
claimed	O
to	O
manage	O
split	O
objects	O
in	O
such	O
a	O
way	O
that	O
schizophrenia	B-Application
was	O
no	O
longer	O
a	O
problem	O
but	O
a	O
facilitator	O
for	O
more	O
flexible	O
designs	O
.	O
</s>
<s>
A	O
later	O
paper	O
by	O
the	O
DCI	O
authors	O
claims	O
that	O
self-schizophrenia	O
remains	O
a	O
problem	O
in	O
role-oriented	B-General_Concept
programming	I-General_Concept
using	O
a	O
counter-example	O
based	O
on	O
a	O
modified	O
implementation	O
of	O
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
As	O
such	O
,	O
DCI	O
sacrifices	O
the	O
advantages	O
of	O
inheritance	O
for	O
the	O
complete	O
avoidance	O
of	O
its	O
shortcomings	O
,	O
while	O
Role	B-General_Concept
Oriented	O
Programming	O
takes	O
a	O
mitigation	O
approach	O
,	O
awarding	O
importance	O
to	O
the	O
balancing	O
of	O
the	O
dangers	O
with	O
its	O
popular	O
advantages	O
.	O
</s>
