<s>
The	O
fragile	B-Application
base	I-Application
class	I-Application
problem	I-Application
is	O
a	O
fundamental	O
architectural	O
problem	O
of	O
object-oriented	B-Language
programming	I-Language
systems	I-Language
where	O
base	O
classes	O
(	O
superclasses	O
)	O
are	O
considered	O
"	O
fragile	O
"	O
because	O
seemingly	O
safe	O
modifications	O
to	O
a	O
base	O
class	O
,	O
when	O
inherited	O
by	O
the	O
derived	O
classes	O
,	O
may	O
cause	O
the	O
derived	O
classes	O
to	O
malfunction	O
.	O
</s>
<s>
Another	O
alternative	O
solution	O
could	O
be	O
to	O
have	O
an	O
interface	B-Application
instead	O
of	O
superclass	O
.	O
</s>
<s>
The	O
fragile	B-Application
base	I-Application
class	I-Application
problem	I-Application
has	O
been	O
blamed	O
on	O
open	B-Algorithm
recursion	I-Algorithm
(	O
dynamic	O
dispatch	O
of	O
methods	O
on	O
this	B-Application
)	O
,	O
with	O
the	O
suggestion	O
that	O
invoking	O
methods	O
on	O
this	B-Application
default	O
to	O
closed	O
recursion	O
(	O
static	O
dispatch	O
,	O
early	O
binding	O
)	O
rather	O
than	O
open	B-Algorithm
recursion	I-Algorithm
(	O
dynamic	O
dispatch	O
,	O
late	O
binding	O
)	O
,	O
only	O
using	O
open	B-Algorithm
recursion	I-Algorithm
when	O
it	O
is	O
specifically	O
requested	O
;	O
external	O
calls	O
(	O
not	O
using	O
this	B-Application
)	O
would	O
be	O
dynamically	O
dispatched	O
as	O
usual	O
.	O
</s>
<s>
The	O
following	O
trivial	O
example	O
is	O
written	O
in	O
the	O
Java	B-Language
programming	I-Language
language	I-Language
and	O
shows	O
how	O
a	O
seemingly	O
safe	O
modification	O
of	O
a	O
base	O
class	O
can	O
cause	O
an	O
inheriting	O
subclass	O
to	O
malfunction	O
by	O
entering	O
an	O
infinite	O
recursion	O
which	O
will	O
result	O
in	O
a	O
stack	B-Error_Name
overflow	I-Error_Name
.	O
</s>
<s>
a	O
call	O
to	O
the	O
dynamically	O
bound	O
method	O
inc2( )	O
on	O
an	O
instance	O
of	O
Sub	O
will	O
cause	O
an	O
infinite	O
recursion	O
between	O
itself	O
and	O
the	O
method	O
inc1( )	O
of	O
the	O
super-class	O
and	O
eventually	O
cause	O
a	O
stack	B-Error_Name
overflow	I-Error_Name
.	O
</s>
<s>
This	B-Application
problem	O
could	O
have	O
been	O
avoided	O
,	O
by	O
declaring	O
the	O
methods	O
in	O
the	O
superclass	O
as	O
final	O
,	O
which	O
would	O
make	O
it	O
impossible	O
for	O
a	O
sub-class	O
to	O
override	O
them	O
.	O
</s>
<s>
However	O
,	O
this	B-Application
is	O
not	O
always	O
desirable	O
or	O
possible	O
.	O
</s>
<s>
Objective-C	B-Language
has	O
categories	O
as	O
well	O
as	O
non-fragile	O
instance	O
variables	O
.	O
</s>
<s>
Component	B-Language
Pascal	I-Language
deprecates	O
superclass	O
calls	O
.	O
</s>
<s>
Java	B-Language
,	O
C++	B-Language
(	O
Since	O
C++11	O
)	O
and	O
D	B-Application
allow	O
inheritance	B-Language
or	O
overriding	O
a	O
class	O
method	O
to	O
be	O
prohibited	O
by	O
labeling	O
a	O
declaration	O
of	O
a	O
class	O
or	O
method	O
,	O
respectively	O
,	O
with	O
the	O
keyword	O
"	O
final	O
"	O
.	O
</s>
<s>
In	O
the	O
book	O
Effective	O
Java	B-Language
,	O
author	O
Joshua	O
Bloch	O
writes	O
(	O
in	O
item	O
17	O
)	O
that	O
programmers	O
should	O
"	O
Design	O
and	O
document	O
for	O
inheritance	B-Language
or	O
else	O
prohibit	O
it	O
"	O
.	O
</s>
<s>
C#	B-Application
and	O
VB.NET	B-Language
like	O
Java	B-Language
have	O
"	O
sealed	O
"	O
and	O
"	O
Not	O
Inheritable	O
"	O
class	O
declaration	O
keywords	O
to	O
prohibit	O
inheritance	B-Language
,	O
and	O
require	O
a	O
subclass	O
to	O
use	O
keyword	O
"	O
override	O
"	O
on	O
overriding	O
methods	O
,	O
the	O
same	O
solution	O
later	O
adopted	O
by	O
Scala	B-Application
.	O
</s>
<s>
Scala	B-Application
require	O
a	O
subclass	O
to	O
use	O
keyword	O
"	O
override	O
"	O
explicitly	O
in	O
order	O
to	O
override	O
a	O
parent	O
class	O
method	O
.	O
</s>
<s>
In	O
the	O
book	O
"	O
Programming	O
in	O
Scala	B-Application
,	O
2nd	O
Edition	O
"	O
,	O
the	O
author	O
writes	O
that	O
(	O
with	O
modifications	O
here	O
)	O
If	O
there	O
was	O
no	O
method	O
f( )	O
,	O
the	O
client	O
’s	O
original	O
implementation	O
of	O
method	O
f( )	O
could	O
not	O
have	O
had	O
an	O
override	O
modifier	O
.	O
</s>
<s>
In	O
Kotlin	B-Language
classes	O
and	O
methods	O
are	O
final	O
by	O
default	O
.	O
</s>
<s>
To	O
enable	O
the	O
class	B-Language
inheritance	I-Language
,	O
the	O
class	O
should	O
be	O
marked	O
with	O
the	O
open	O
modifier	O
.	O
</s>
<s>
Julia	B-Application
allows	O
only	O
subtyping	O
of	O
abstract	O
types	O
and	O
uses	O
composition	O
as	O
an	O
alternative	O
to	O
inheritance	B-Language
.	O
</s>
