Interfaces and ABCs

Discussion in 'C++' started by Paulo Matos, Dec 2, 2006.

  1. Paulo Matos

    Paulo Matos Guest

    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
     
    Paulo Matos, Dec 2, 2006
    #1
    1. Advertising

  2. Paulo Matos

    Ian Collins Guest

    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.
     
    Ian Collins, Dec 2, 2006
    #2
    1. Advertising

  3. On Dec 2, 11:39 pm, "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?


    Wrong.

    Its rare that an applications performance problems are due to virtual
    method calls. The true problems almost always lay elsewhere.
     
    andrewmcdonagh, Dec 2, 2006
    #3
  4. Paulo Matos

    Salt_Peter Guest

    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.
     
    Salt_Peter, Dec 3, 2006
    #4
  5. Paulo Matos

    kwikius Guest

    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
     
    kwikius, Dec 3, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven T. Hatton

    Polymorphism, iterators and ABCs?

    Steven T. Hatton, Aug 7, 2005, in forum: C++
    Replies:
    5
    Views:
    375
    Axter
    Sep 2, 2005
  2. Mark P

    Interfaces without ABCs?

    Mark P, Sep 13, 2005, in forum: C++
    Replies:
    6
    Views:
    344
    Alf P. Steinbach
    Sep 13, 2005
  3. =?iso-8859-1?q?Ernesto_Basc=F3n?=

    Opaque pointers, templates and ABCs

    =?iso-8859-1?q?Ernesto_Basc=F3n?=, Oct 25, 2006, in forum: C++
    Replies:
    3
    Views:
    395
    Roland Pibinger
    Oct 25, 2006
  4. Bart Simpson
    Replies:
    4
    Views:
    311
    James Kanze
    Jun 3, 2007
  5. andrew cooke

    ABCs, functions, and __call__ (Python3)

    andrew cooke, Jan 17, 2009, in forum: Python
    Replies:
    1
    Views:
    307
    andrew cooke
    Jan 17, 2009
Loading...

Share This Page