<s>
In	O
software	O
systems	O
,	O
encapsulation	B-Application
refers	O
to	O
the	O
bundling	O
of	O
data	O
with	O
the	O
mechanisms	O
or	O
methods	O
that	O
operate	O
on	O
the	O
data	O
.	O
</s>
<s>
Encapsulation	B-Application
allows	O
developers	O
to	O
present	O
a	O
consistent	O
and	O
usable	O
interface	O
which	O
is	O
independent	O
of	O
how	O
a	O
system	O
is	O
implemented	O
internally	O
.	O
</s>
<s>
As	O
one	O
example	O
,	O
encapsulation	B-Application
can	O
be	O
used	O
to	O
hide	O
the	O
values	O
or	O
state	O
of	O
a	O
structured	O
data	O
object	O
inside	O
a	O
class	O
,	O
preventing	O
direct	O
access	O
to	O
them	O
by	O
clients	O
in	O
a	O
way	O
that	O
could	O
expose	O
hidden	O
implementation	O
details	O
or	O
violate	O
state	O
invariance	O
maintained	O
by	O
the	O
methods	O
.	O
</s>
<s>
All	O
object-oriented	B-Language
programming	I-Language
(	O
OOP	O
)	O
systems	O
support	O
encapsulation	B-Application
,	O
but	O
encapsulation	B-Application
is	O
not	O
unique	O
to	O
OOP	O
.	O
</s>
<s>
Implementations	O
of	O
abstract	O
data	O
types	O
,	O
modules	B-Architecture
,	O
and	O
libraries	B-Library
,	O
among	O
other	O
systems	O
,	O
also	O
offer	O
encapsulation	B-Application
.	O
</s>
<s>
In	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
,	O
and	O
other	O
related	O
fields	O
,	O
encapsulation	B-Application
refers	O
to	O
one	O
of	O
two	O
related	O
but	O
distinct	O
notions	O
,	O
and	O
sometimes	O
to	O
the	O
combination	O
thereof	O
:	O
</s>
<s>
Some	O
programming	O
language	O
researchers	O
and	O
academics	O
use	O
the	O
first	O
meaning	O
alone	O
or	O
in	O
combination	O
with	O
the	O
second	O
as	O
a	O
distinguishing	O
feature	O
of	O
object-oriented	B-Language
programming	I-Language
,	O
while	O
some	O
programming	O
languages	O
that	O
provide	O
lexical	B-Language
closures	I-Language
view	O
encapsulation	B-Application
as	O
a	O
feature	O
of	O
the	O
language	O
orthogonal	O
to	O
object	O
orientation	O
.	O
</s>
<s>
The	O
second	O
definition	O
is	O
motivated	O
by	O
the	O
fact	O
that	O
in	O
many	O
object-oriented	B-Language
languages	I-Language
,	O
and	O
other	O
related	O
fields	O
,	O
the	O
components	O
are	O
not	O
hidden	O
automatically	O
and	O
this	O
can	O
be	O
overridden	O
;	O
thus	O
,	O
information	B-Application
hiding	I-Application
is	O
defined	O
as	O
a	O
separate	O
notion	O
by	O
those	O
who	O
prefer	O
the	O
second	O
definition	O
.	O
</s>
<s>
The	O
features	O
of	O
encapsulation	B-Application
are	O
supported	O
using	O
classes	O
in	O
most	O
object-oriented	B-Language
languages	I-Language
,	O
although	O
other	O
alternatives	O
also	O
exist	O
.	O
</s>
<s>
The	O
authors	O
of	O
Design	O
Patterns	O
discuss	O
the	O
tension	O
between	O
inheritance	B-Language
and	O
encapsulation	B-Application
at	O
length	O
and	O
state	O
that	O
in	O
their	O
experience	O
,	O
designers	O
overuse	O
inheritance	B-Language
.	O
</s>
<s>
They	O
claim	O
that	O
inheritance	B-Language
often	O
breaks	O
encapsulation	B-Application
,	O
given	O
that	O
inheritance	B-Language
exposes	O
a	O
subclass	O
to	O
the	O
details	O
of	O
its	O
parent	O
's	O
implementation	O
.	O
</s>
<s>
As	O
described	O
by	O
the	O
yo-yo	B-Application
problem	I-Application
,	O
overuse	O
of	O
inheritance	B-Language
and	O
therefore	O
encapsulation	B-Application
,	O
can	O
become	O
too	O
complicated	O
and	O
hard	O
to	O
debug	O
.	O
</s>
<s>
Under	O
the	O
definition	O
that	O
encapsulation	B-Application
"	O
can	O
be	O
used	O
to	O
hide	O
data	O
members	O
and	O
member	O
functions	O
"	O
,	O
the	O
internal	O
representation	O
of	O
an	O
object	O
is	O
generally	O
hidden	O
from	O
view	O
outside	O
of	O
the	O
object	O
's	O
definition	O
.	O
</s>
<s>
A	O
supposed	O
benefit	O
of	O
encapsulation	B-Application
is	O
that	O
it	O
can	O
reduce	O
system	O
complexity	O
,	O
and	O
thus	O
increase	O
robustness	B-Application
,	O
by	O
allowing	O
the	O
developer	O
to	O
limit	O
the	O
interdependencies	O
between	O
software	O
components	O
.	O
</s>
<s>
Some	O
languages	O
like	O
Smalltalk	B-Application
and	O
Ruby	B-Language
only	O
allow	O
access	O
via	O
object	O
methods	O
,	O
but	O
most	O
others	O
(	O
e.g.	O
,	O
C++	B-Language
,	O
C#	B-Application
,	O
Delphi	B-Language
or	O
Java	B-Language
)	O
offer	O
the	O
programmer	O
a	O
degree	O
of	O
control	O
over	O
what	O
is	O
hidden	O
,	O
typically	O
via	O
keywords	O
like	O
public	O
and	O
private	O
.	O
</s>
<s>
ISO	O
C++	B-Language
standard	O
refers	O
to	O
protected	O
,	O
private	O
and	O
public	O
as	O
"	O
access	O
specifiers	O
"	O
and	O
that	O
they	O
do	O
not	O
"	O
hide	O
any	O
information	O
"	O
.	O
</s>
<s>
Information	B-Application
hiding	I-Application
is	O
accomplished	O
by	O
furnishing	O
a	O
compiled	O
version	O
of	O
the	O
source	O
code	O
that	O
is	O
interfaced	O
via	O
a	O
header	O
file	O
.	O
</s>
<s>
Almost	O
always	O
,	O
there	O
is	O
a	O
way	O
to	O
override	O
such	O
protection	O
usually	O
via	O
reflection	B-Language
API	I-Language
(	O
Ruby	B-Language
,	O
Java	B-Language
,	O
C#	B-Application
,	O
etc	O
.	O
</s>
<s>
)	O
,	O
sometimes	O
by	O
mechanism	O
like	O
name	B-Language
mangling	I-Language
(	O
Python	B-Language
)	O
,	O
or	O
special	O
keyword	O
usage	O
like	O
friend	O
in	O
C++	B-Language
.	O
</s>
<s>
Systems	O
that	O
provide	O
object-level	O
capability-based	O
security	O
(	O
adhering	O
to	O
the	O
object-capability	O
model	O
)	O
are	O
an	O
exception	O
,	O
and	O
guarantee	O
strong	O
encapsulation	B-Application
.	O
</s>
<s>
Languages	O
like	O
C++	B-Language
,	O
C#	B-Application
,	O
Java	B-Language
,	O
PHP	B-Application
,	O
Swift	B-Application
,	O
and	O
Delphi	B-Language
offer	O
ways	O
to	O
restrict	O
access	O
to	O
data	O
fields	O
.	O
</s>
<s>
Below	O
is	O
an	O
example	O
in	O
C#	B-Application
that	O
shows	O
how	O
access	O
to	O
a	O
data	O
field	O
can	O
be	O
restricted	O
through	O
the	O
use	O
of	O
a	O
private	O
keyword	O
:	O
</s>
<s>
Below	O
is	O
an	O
example	O
in	O
Java	B-Language
:	O
</s>
<s>
Encapsulation	B-Application
is	O
also	O
possible	O
in	O
non-object-oriented	O
languages	O
.	O
</s>
<s>
In	O
C	B-Language
,	O
for	O
example	O
,	O
a	O
structure	O
can	O
be	O
declared	O
in	O
the	O
public	O
API	O
via	O
the	O
header	O
file	O
for	O
a	O
set	O
of	O
functions	O
that	O
operate	O
on	O
an	O
item	O
of	O
data	O
containing	O
data	O
members	O
that	O
are	O
not	O
accessible	O
to	O
clients	O
of	O
the	O
API	O
with	O
the	O
extern	O
keyword	O
.	O
</s>
<s>
Clients	O
call	O
the	O
API	O
functions	O
to	O
allocate	O
,	O
operate	O
on	O
,	O
and	O
deallocate	O
objects	O
of	O
an	O
opaque	B-General_Concept
data	I-General_Concept
type	I-General_Concept
.	O
</s>
<s>
Below	O
is	O
an	O
example	O
of	O
Python	B-Language
,	O
which	O
does	O
not	O
support	O
variable	O
access	O
restrictions	O
.	O
</s>
