473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Interfaces and ABCs

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

Dec 2 '06 #1
4 1419
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.
Dec 2 '06 #2


On Dec 2, 11:39 pm, "Paulo Matos" <pocma...@gmail.comwrote:
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.

Dec 2 '06 #3

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.

Dec 3 '06 #4

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

Dec 3 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: baylor | last post by:
In C#, an interface cannot mark any method as static. i'm told the ILASM supports it but i've never tested that Two questions. First, why? OK, i've heard the reason about interfaces being...
17
by: Victor Bazarov | last post by:
Interesting article. However, it starts with an example which I find rather misleading. I hope the author (Christopher Diggins) wouldn't mind if I post a quote from the article. I know he...
7
by: Mark P | last post by:
I working frequently with similar but distinct geometric objects. For example, a collection of Edge classes. All Edge classes should support certain basic functions, such as getTail(), getTip,...
2
by: dex | last post by:
hi, i am just trying to implement Iterator pattern in C++, I just stuck up with how to use interfaces, Please help me in how to use interfaces in C++, Can i use abstract base class instead of...
0
by: Michael Bruzdzinski | last post by:
I am hoping that some one in the DB2 community is a 'pack rat' and has a copy of the article "The ABCs of Plans and Packages" by Nicola Nur, which was written in 1994. It appeared in the Database...
22
by: RSH | last post by:
Hi, I have been reading on interfaces working on samples I've run across on the web. For the life of me I cannot seem to grasp them. It appears to me that interfaces are simply blueprints to...
8
by: PeterBraden1 | last post by:
Hi, Does anyone know what the state of progress with interfaces for python (last I can see is http://www.python.org/dev/peps/pep-0245/) I would argue that interfaces/(similar feature) are...
28
by: jmDesktop | last post by:
Studying OOP and noticed that Python does not have Interfaces. Is that correct? Is my schooling for nought on these OOP concepts if I use Python. Am I losing something if I don't use the...
5
by: Boris Borcic | last post by:
Given the ABC innovation, maybe an infix syntax for isinstance() would be good. Possibilities : - stealing "is" away from object identity. As a motivation, true use cases for testing object...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.