Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Interfaces and ABCs

Reply
Thread Tools

Interfaces and ABCs

 
 
Paulo Matos
Guest
Posts: n/a
 
      12-02-2006
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

 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      12-02-2006
Paulo Matos wrote:
> 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.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
andrewmcdonagh
Guest
Posts: n/a
 
      12-02-2006


On Dec 2, 11:39 pm, "Paulo Matos" <(E-Mail Removed)> wrote:
> 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.

 
Reply With Quote
 
Salt_Peter
Guest
Posts: n/a
 
      12-03-2006

Paulo Matos wrote:
> 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.

 
Reply With Quote
 
kwikius
Guest
Posts: n/a
 
      12-03-2006

Paulo Matos wrote:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ABCs, functions, and __call__ (Python3) andrew cooke Python 1 01-17-2009 03:45 AM
ABCs (abstract base classes) and linkage problems Bart Simpson C++ 4 06-03-2007 08:54 PM
Opaque pointers, templates and ABCs =?iso-8859-1?q?Ernesto_Basc=F3n?= C++ 3 10-25-2006 08:53 PM
Interfaces without ABCs? Mark P C++ 6 09-13-2005 08:16 AM
Polymorphism, iterators and ABCs? Steven T. Hatton C++ 5 09-02-2005 12:42 AM



Advertisments