<s>
The	O
bridge	B-Language
pattern	I-Language
is	O
a	O
design	O
pattern	O
used	O
in	O
software	B-General_Concept
engineering	I-General_Concept
that	O
is	O
meant	O
to	O
"	O
decouple	O
an	O
abstraction	B-Application
from	O
its	O
implementation	O
so	O
that	O
the	O
two	O
can	O
vary	O
independently	O
"	O
,	O
introduced	O
by	O
the	O
Gang	O
of	O
Four	O
.	O
</s>
<s>
The	O
bridge	O
uses	O
encapsulation	B-Application
,	O
aggregation	O
,	O
and	O
can	O
use	O
inheritance	B-Language
to	O
separate	O
responsibilities	O
into	O
different	O
classes	O
.	O
</s>
<s>
When	O
a	O
class	O
varies	O
often	O
,	O
the	O
features	O
of	O
object-oriented	B-Language
programming	I-Language
become	O
very	O
useful	O
because	O
changes	O
to	O
a	O
program	B-Application
's	O
code	O
can	O
be	O
made	O
easily	O
with	O
minimal	O
prior	O
knowledge	O
about	O
the	O
program	B-Application
.	O
</s>
<s>
The	O
bridge	B-Language
pattern	I-Language
is	O
useful	O
when	O
both	O
the	O
class	O
and	O
what	O
it	O
does	O
vary	O
often	O
.	O
</s>
<s>
The	O
class	O
itself	O
can	O
be	O
thought	O
of	O
as	O
the	O
abstraction	B-Application
and	O
what	O
the	O
class	O
can	O
do	O
as	O
the	O
implementation	O
.	O
</s>
<s>
The	O
bridge	B-Language
pattern	I-Language
can	O
also	O
be	O
thought	O
of	O
as	O
two	O
layers	O
of	O
abstraction	B-Application
.	O
</s>
<s>
When	O
there	O
is	O
only	O
one	O
fixed	O
implementation	O
,	O
this	O
pattern	O
is	O
known	O
as	O
the	O
Pimpl	O
idiom	O
in	O
the	O
C++	B-Language
world	O
.	O
</s>
<s>
The	O
bridge	B-Language
pattern	I-Language
is	O
often	O
confused	O
with	O
the	O
adapter	O
pattern	O
,	O
and	O
is	O
often	O
implemented	O
using	O
the	O
object	O
adapter	O
pattern	O
;	O
e.g.	O
,	O
in	O
the	O
Java	B-Language
code	I-Language
below	O
.	O
</s>
<s>
Variant	O
:	O
The	O
implementation	O
can	O
be	O
decoupled	O
even	O
more	O
by	O
deferring	O
the	O
presence	O
of	O
the	O
implementation	O
to	O
the	O
point	O
where	O
the	O
abstraction	B-Application
is	O
utilized	O
.	O
</s>
<s>
The	O
Bridge	O
design	O
pattern	O
is	O
one	O
of	O
the	O
twenty-three	O
well-known	O
GoF	O
design	O
patterns	O
that	O
describe	O
how	O
to	O
solve	O
recurring	O
design	O
problems	O
to	O
design	O
flexible	O
and	O
reusable	O
object-oriented	B-Language
software	O
,	O
that	O
is	O
,	O
objects	O
that	O
are	O
easier	O
to	O
implement	O
,	O
change	O
,	O
test	O
,	O
and	O
reuse	O
.	O
</s>
<s>
An	O
abstraction	B-Application
and	O
its	O
implementation	O
should	O
be	O
defined	O
and	O
extended	O
independently	O
from	O
each	O
other	O
.	O
</s>
<s>
A	O
compile-time	O
binding	O
between	O
an	O
abstraction	B-Application
and	O
its	O
implementation	O
should	O
be	O
avoided	O
so	O
that	O
an	O
implementation	O
can	O
be	O
selected	O
at	O
run-time	O
.	O
</s>
<s>
But	O
an	O
implementation	O
is	O
bound	O
to	O
the	O
abstraction	B-Application
at	O
compile-time	O
and	O
cannot	O
be	O
changed	O
at	O
run-time	O
.	O
</s>
<s>
Separate	O
an	O
abstraction	B-Application
(	O
Abstraction	B-Application
)	O
from	O
its	O
implementation	O
(	O
Implementor	O
)	O
by	O
putting	O
them	O
in	O
separate	O
class	O
hierarchies	O
.	O
</s>
<s>
Implement	O
the	O
Abstraction	B-Application
in	O
terms	O
of	O
(	O
by	O
delegating	O
to	O
)	O
an	O
Implementor	O
object	O
.	O
</s>
<s>
This	O
enables	O
to	O
configure	O
an	O
Abstraction	B-Application
with	O
an	O
Implementor	O
object	O
at	O
run-time	O
.	O
</s>
<s>
See	O
also	O
the	O
Unified	B-Language
Modeling	I-Language
Language	I-Language
class	O
and	O
sequence	O
diagram	O
below	O
.	O
</s>
<s>
In	O
the	O
above	O
Unified	B-Language
Modeling	I-Language
Language	I-Language
class	O
diagram	O
,	O
an	O
abstraction	B-Application
(	O
Abstraction	B-Application
)	O
is	O
not	O
implemented	O
as	O
usual	O
in	O
a	O
single	O
inheritance	B-Language
hierarchy	I-Language
.	O
</s>
<s>
an	O
abstraction	B-Application
(	O
Abstraction	B-Application
)	O
and	O
a	O
separate	O
hierarchy	O
for	O
its	O
implementation	O
(	O
Implementor	O
)	O
,	O
which	O
makes	O
the	O
two	O
independent	O
from	O
each	O
other	O
.	O
</s>
<s>
Bridge	B-Language
pattern	I-Language
compose	O
objects	O
in	O
tree	O
structure	O
.	O
</s>
<s>
It	O
decouples	O
abstraction	B-Application
from	O
implementation	O
.	O
</s>
<s>
Here	O
abstraction	B-Application
represents	O
the	O
client	O
from	O
which	O
the	O
objects	O
will	O
be	O
called	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
the	O
abstraction	B-Application
takes	O
an	O
instance	O
of	O
the	O
implementation	O
class	O
and	O
runs	O
its	O
method	O
.	O
</s>
<s>
The	O
following	O
Java	B-Language
program	B-Application
defines	O
a	O
bank	O
account	O
that	O
separates	O
the	O
account	O
operations	O
from	O
the	O
logging	O
of	O
these	O
operations	O
.	O
</s>
