<s>
Class-based	B-Application
programming	I-Application
,	O
or	O
more	O
commonly	O
class-orientation	B-Application
,	O
is	O
a	O
style	O
of	O
object-oriented	B-Language
programming	I-Language
(	O
OOP	O
)	O
in	O
which	O
inheritance	B-Language
occurs	O
via	O
defining	O
classes	O
of	O
objects	O
,	O
instead	O
of	O
inheritance	B-Language
occurring	O
via	O
the	O
objects	O
alone	O
(	O
compare	O
prototype-based	B-Application
programming	I-Application
)	O
.	O
</s>
<s>
The	O
most	O
popular	O
and	O
developed	O
model	O
of	O
OOP	O
is	O
a	O
class-based	B-Application
model	O
,	O
instead	O
of	O
an	O
object-based	O
model	O
.	O
</s>
<s>
In	O
this	O
model	O
,	O
objects	O
are	O
entities	O
that	O
combine	O
state	B-Application
(	O
i.e.	O
,	O
data	O
)	O
,	O
behavior	O
(	O
i.e.	O
,	O
procedures	O
,	O
or	O
methods	O
)	O
and	O
identity	B-Application
(	O
unique	O
existence	O
among	O
all	O
other	O
objects	O
)	O
.	O
</s>
<s>
The	O
structure	B-General_Concept
and	O
behavior	O
of	O
an	O
object	O
are	O
defined	O
by	O
a	O
class	O
,	O
which	O
is	O
a	O
definition	O
,	O
or	O
blueprint	B-Application
,	O
of	O
all	O
objects	O
of	O
a	O
specific	O
type	O
.	O
</s>
<s>
An	O
object	O
is	O
similar	O
to	O
a	O
structure	B-General_Concept
,	O
with	O
the	O
addition	O
of	O
method	B-Language
pointers	O
,	O
member	O
access	O
control	O
,	O
and	O
an	O
implicit	O
data	O
member	O
which	O
locates	O
instances	O
of	O
the	O
class	O
(	O
i.e.	O
,	O
objects	O
of	O
the	O
class	O
)	O
in	O
the	O
class	O
hierarchy	O
(	O
essential	O
for	O
runtime	O
inheritance	B-Language
features	O
)	O
.	O
</s>
<s>
Encapsulation	B-Application
prevents	O
users	O
from	O
breaking	O
the	O
invariants	B-Application
of	O
the	O
class	O
,	O
which	O
is	O
useful	O
because	O
it	O
allows	O
the	O
implementation	O
of	O
a	O
class	O
of	O
objects	O
to	O
be	O
changed	O
for	O
aspects	O
not	O
exposed	O
in	O
the	O
interface	O
without	O
impact	O
to	O
user	O
code	O
.	O
</s>
<s>
The	O
definitions	O
of	O
encapsulation	B-Application
focus	O
on	O
the	O
grouping	O
and	O
packaging	O
of	O
related	O
information	O
(	O
cohesion	O
)	O
rather	O
than	O
security	O
issues	O
.	O
</s>
<s>
In	O
class-based	B-Application
programming	I-Application
,	O
inheritance	B-Language
is	O
done	O
by	O
defining	O
new	O
classes	O
as	O
extensions	O
of	O
existing	O
classes	O
:	O
the	O
existing	O
class	O
is	O
the	O
parent	O
class	O
and	O
the	O
new	O
class	O
is	O
the	O
child	O
class	O
.	O
</s>
<s>
If	O
a	O
child	O
class	O
has	O
only	O
one	O
parent	O
class	O
,	O
this	O
is	O
known	O
as	O
single	O
inheritance	B-Language
,	O
while	O
if	O
a	O
child	O
class	O
can	O
have	O
more	O
than	O
one	O
parent	O
class	O
,	O
this	O
is	O
known	O
as	O
multiple	B-Application
inheritance	I-Application
.	O
</s>
<s>
This	O
organizes	O
classes	O
into	O
a	O
hierarchy	O
,	O
either	O
a	O
tree	O
(	O
if	O
single	O
inheritance	B-Language
)	O
or	O
lattice	O
(	O
if	O
multiple	B-Application
inheritance	I-Application
)	O
.	O
</s>
<s>
The	O
defining	O
feature	O
of	O
inheritance	B-Language
is	O
that	O
both	O
interface	O
and	O
implementation	O
are	O
inherited	O
;	O
if	O
only	O
interface	O
is	O
inherited	O
,	O
this	O
is	O
known	O
as	O
interface	B-Application
inheritance	I-Application
or	O
subtyping	O
.	O
</s>
<s>
Inheritance	B-Language
can	O
also	O
be	O
done	O
without	O
classes	O
,	O
as	O
in	O
prototype-based	B-Application
programming	I-Application
.	O
</s>
<s>
Class-based	B-Application
languages	I-Application
,	O
or	O
,	O
to	O
be	O
more	O
precise	O
,	O
typed	O
languages	O
,	O
where	O
subclassing	O
is	O
the	O
only	O
way	O
of	O
subtyping	O
,	O
have	O
been	O
criticized	O
for	O
mixing	O
up	O
implementations	O
and	O
interfacesthe	O
essential	O
principle	O
in	O
object-oriented	B-Language
programming	I-Language
.	O
</s>
<s>
The	O
critics	O
say	O
one	O
might	O
create	O
a	O
bag	O
class	O
that	O
stores	O
a	O
collection	B-Application
of	O
objects	O
,	O
then	O
extend	O
it	O
to	O
make	O
a	O
new	O
class	O
called	O
a	O
set	O
class	O
where	O
the	O
duplication	O
of	O
objects	O
is	O
eliminated	O
.	O
</s>
<s>
The	O
problem	O
arises	O
precisely	O
because	O
subclassing	O
implies	O
subtyping	O
even	O
in	O
the	O
instances	O
where	O
the	O
principle	O
of	O
subtyping	O
,	O
known	O
as	O
the	O
Liskov	B-Application
substitution	I-Application
principle	I-Application
,	O
does	O
not	O
hold	O
.	O
</s>
<s>
Most	O
current	O
object-oriented	B-Language
languages	I-Language
distinguish	O
subtyping	O
and	O
subclassing	O
,	O
however	O
some	O
approaches	O
to	O
design	O
do	O
not	O
.	O
</s>
<s>
Also	O
,	O
another	O
common	O
example	O
is	O
that	O
a	O
person	O
object	O
created	O
from	O
a	O
child	O
class	O
cannot	O
become	O
an	O
object	O
of	O
parent	O
class	O
because	O
a	O
child	O
class	O
and	O
a	O
parent	O
class	O
inherit	O
a	O
person	O
class	O
but	O
class-based	B-Application
languages	I-Application
mostly	O
do	O
not	O
allow	O
to	O
change	O
the	O
kind	O
of	O
class	O
of	O
the	O
object	O
at	O
runtime	O
.	O
</s>
<s>
For	O
class-based	B-Application
languages	I-Application
,	O
this	O
restriction	O
is	O
essential	O
in	O
order	O
to	O
preserve	O
unified	O
view	O
of	O
the	O
class	O
to	O
its	O
users	O
.	O
</s>
<s>
The	O
users	O
should	O
not	O
need	O
to	O
care	O
whether	O
one	O
of	O
the	O
implementations	O
of	O
a	O
method	B-Language
happens	O
to	O
cause	O
changes	O
that	O
break	O
the	O
invariants	B-Application
of	O
the	O
class	O
.	O
</s>
<s>
Polymorphism	O
can	O
be	O
used	O
to	O
preserve	O
the	O
relevant	O
interfaces	O
even	O
when	O
such	O
changes	O
are	O
done	O
,	O
because	O
the	O
objects	O
are	O
viewed	O
as	O
black	O
box	O
abstractions	O
and	O
accessed	O
via	O
object	O
identity	B-Application
.	O
</s>
<s>
Although	O
Simula	B-Language
introduced	O
the	O
class	O
abstraction	O
,	O
the	O
canonical	O
example	O
of	O
a	O
class-based	B-Application
language	I-Application
is	O
Smalltalk	B-Application
.	O
</s>
<s>
Others	O
include	O
PHP	B-Application
,	O
C++	B-Language
,	O
Java	B-Language
,	O
C#	B-Application
,	O
and	O
Objective-C	B-Language
.	O
</s>
