Re: Why ABC's make bad Interfaces
From: Universe (universe_at_covad.net)
Date: 04/10/04
- Next message: Universe: "Re: Problem: some properties are perculiar to more than 1 superclass"
- Previous message: Daniel T.: "Re: Composite. Again!"
- In reply to: christopher diggins: "Re: Why ABC's make bad Interfaces"
- Next in thread: Universe: "Re: Why ABC's make bad Interfaces"
- Reply: Universe: "Re: Why ABC's make bad Interfaces"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 9 Apr 2004 21:17:05 -0400
"christopher diggins" <cdiggins@videotron.ca> wrote in message news:gzAdc.89950
> When I write a class that implements an interface it should not be an
> implicit agreement to make those functions virtual. This conflicts with my
> intentions most of the time.
Best idiomatic pratice with a C++ base class that is meant to serve as the
API for a hierarchy is to declare all methods as 'virtual', without data
members.
Each derived class should declare the data members it requires. If there is
a need for the base class to have a data member it should accessed
via a protected base class member function.
> The
> fact that those functions become virtual is something that is wrongheadly
> imposed by many language implementations.
Either a C++ base class method IS or IS NOT declared 'virtual'. There's no
ambiguity.
> This is why an ABC is not an Interfaces.
Many C++ coders are happily using ABC's as type class hierarchy interfaces.
> At the risk of repeating myself, you can have interfaces at a fraction of
> the speed and size overhead of ABC's.
What's so large and slow about vtbls as employed with C++ class type
hierarchies?
Further one is not limited to inheritance with C++. One may also
use super speedy generics that allow for polymorphic behavior given
the same API.
Elliott
-- http://www.univercenet.net It has heavily contributed to my subsequent opinion that creating confidence in the correctness of his design was the most important but hardest aspect of the programmer's task. In a world *obsessed with speed* ["Craftite" just do it -Ell], this was not a universally popular notion." ~EW Dijkstra
- Next message: Universe: "Re: Problem: some properties are perculiar to more than 1 superclass"
- Previous message: Daniel T.: "Re: Composite. Again!"
- In reply to: christopher diggins: "Re: Why ABC's make bad Interfaces"
- Next in thread: Universe: "Re: Why ABC's make bad Interfaces"
- Reply: Universe: "Re: Why ABC's make bad Interfaces"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|