Interfaces and ABCs

P

Paulo Matos

Hi all,

C++ FAQ Lite points you out to ABCs to define interfaces in C++,
however, in a well-defined big system which may consist of a huge
number of interfaces, the use of ABCs may incur in a very heave
performance penalty due to virtual functions, right?

Are there any alternatives to define "interfaces" in C++ without the
use of ABCs?

Regards,

Paulo Matos
 
I

Ian Collins

Paulo said:
Hi all,

C++ FAQ Lite points you out to ABCs to define interfaces in C++,
however, in a well-defined big system which may consist of a huge
number of interfaces, the use of ABCs may incur in a very heave
performance penalty due to virtual functions, right?
Probably wrong. On most modern implementations the cost of a virtual
method call is trivial.
Are there any alternatives to define "interfaces" in C++ without the
use of ABCs?
Templates and traits can offer an alternative.
 
A

andrewmcdonagh

Hi all,

C++ FAQ Lite points you out to ABCs to define interfaces in C++,
however, in a well-defined big system which may consist of a huge
number of interfaces, the use of ABCs may incur in a very heave
performance penalty due to virtual functions, right?

Wrong.

Its rare that an applications performance problems are due to virtual
method calls. The true problems almost always lay elsewhere.
 
S

Salt_Peter

Paulo said:
Hi all,

C++ FAQ Lite points you out to ABCs to define interfaces in C++,
however, in a well-defined big system which may consist of a huge
number of interfaces, the use of ABCs may incur in a very heave
performance penalty due to virtual functions, right?

Are there any alternatives to define "interfaces" in C++ without the
use of ABCs?

Regards,

Paulo Matos

A heavy penalty is paid when a client/employer looks at your code and
says to you: i find your system hard to use or impossible to expand
with. I haven't got the time or money to pay each one of my coders 100
hours just to learn how to use / or modify your code before being
productive. Or: i need special features without modifying the original
library. And i want to be able to add those features right now,
tomorrow and a decade from now.
Not to mention the cost of supporting that client.
From those points of view, the cost of a virtual function call is far,
far down the list of priorities. In fact, the more interfaces you need
to expose, the higher the benefit of using abstract classes. If you
doubt that - that client might very well be you.

The best way to explain the true reason for having ABCs is: the
compiler is now able to help you code since the creator has written
rules guarenteeing that expanding an interface is simple and doing so
will *not* bring down the system. Thats truely priceless.
 
K

kwikius

Paulo said:
Hi all,

C++ FAQ Lite points you out to ABCs to define interfaces in C++,
however, in a well-defined big system which may consist of a huge
number of interfaces, the use of ABCs may incur in a very heave
performance penalty due to virtual functions, right?

Are there any alternatives to define "interfaces" in C++ without the
use of ABCs?


Google for CRTP and see how its used in ATL, WTL.

regards
Andy Little
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top