<s>
In	O
software	B-General_Concept
engineering	I-General_Concept
,	O
a	O
double-chance	B-Language
function	I-Language
is	O
a	O
software	O
design	O
pattern	O
with	O
a	O
strong	O
application	O
in	O
cross-platform	B-Operating_System
and	O
scalable	O
development	O
.	O
</s>
<s>
Consider	O
a	O
graphics	O
API	B-Application
with	O
functions	O
to	O
DrawPoint	O
,	O
DrawLine	O
,	O
and	O
DrawSquare	O
.	O
</s>
<s>
If	O
you	O
were	O
porting	O
this	O
API	B-Application
to	O
a	O
new	O
architecture	O
you	O
would	O
have	O
a	O
choice	O
:	O
implement	O
three	O
different	O
functions	O
natively	O
(	O
taking	O
more	O
time	O
to	O
implement	O
,	O
but	O
likely	O
resulting	O
in	O
faster	O
code	O
)	O
,	O
or	O
write	O
DrawPoint	O
natively	O
,	O
and	O
implement	O
the	O
others	O
as	O
described	O
above	O
using	O
common	O
,	O
cross-platform	B-Operating_System
,	O
code	O
.	O
</s>
<s>
An	O
important	O
example	O
of	O
this	O
approach	O
is	O
the	O
X11	B-Operating_System
graphics	O
system	O
,	O
which	O
can	O
be	O
ported	O
to	O
new	O
graphics	O
hardware	O
by	O
providing	O
a	O
very	O
small	O
number	O
of	O
device-dependent	O
primitives	O
,	O
leaving	O
higher	O
level	O
functions	O
to	O
a	O
hardware-independent	O
layer	O
.	O
</s>
<s>
The	O
double-chance	B-Language
function	I-Language
is	O
an	O
optimal	O
method	O
of	O
creating	O
such	O
an	O
implementation	O
,	O
whereby	O
the	O
first	O
draft	O
of	O
the	O
port	O
can	O
use	O
the	O
"	O
fast	O
to	O
market	O
,	O
slow	O
to	O
run	O
"	O
version	O
with	O
a	O
common	O
DrawPoint	O
function	O
,	O
while	O
later	O
versions	O
can	O
be	O
modified	O
as	O
"	O
slow	O
to	O
market	O
,	O
fast	O
to	O
run	O
"	O
.	O
</s>
<s>
Where	O
the	O
double-chance	B-Language
pattern	O
scores	O
high	O
is	O
that	O
the	O
base	O
API	B-Application
includes	O
the	O
self-supporting	O
implementation	O
given	O
here	O
as	O
part	O
of	O
the	O
null	O
driver	O
,	O
and	O
all	O
other	O
implementations	O
are	O
extensions	O
of	O
this	O
.	O
</s>
<s>
One	O
typical	O
implementation	O
in	O
C++	B-Language
could	O
be	O
:	O
</s>
<s>
If	O
no	O
native	O
implementation	O
exists	O
,	O
then	O
the	O
base	O
class	O
is	O
called	O
,	O
at	O
which	O
point	O
the	O
virtualization	B-Application
takes	O
over	O
and	O
means	O
that	O
CNewGfxAPI::DrawLine	O
is	O
called	O
.	O
</s>
<s>
This	O
gives	O
the	O
CNewGfxAPI	O
class	O
a	O
“	O
second	O
chance	O
”	O
to	O
use	O
native	B-Language
code	I-Language
,	O
if	O
any	O
is	O
available	O
.	O
</s>
<s>
In	O
practice	O
this	O
would	O
be	O
hopelessly	O
slow	O
,	O
but	O
it	O
does	O
demonstrate	O
the	O
possibilities	O
for	O
double-chance	B-Language
functions	I-Language
.	O
</s>
