Frank Schönheit - Sun Microsystems Germany <[EMAIL PROTECTED]> writes:

> (What I intended to say was: what I've learned during reading zillions
> of line of code inherited from others is that patterns which are
> obscured from plain sight are hard to maintain, and thus prone to
> introducing errors. While using cool language features is, well, cool,
> its usefulness sometimes decreases over time, when it comes to
> maintaining the code. KISS. But hey, I'm digressing.)
> 
Generally, true. But aren't we c++ programmers accustomed to an
unprecedented level of obscureness, anyway (at least compared to, say,
a Java coder)? ;-)

So, in this case, about the only change that will break things with
this idiom (and doesn't trigger a compiler error) is that someone
implements method a() or b() in Interface:

struct Interface
{
- virtual void a() = 0;
+ virtual void a() {}
- virtual void b() = 0;
+ virtual void b() {}
};

struct DerivedInterface : public Interface
{
 virtual void c() = 0;
};

struct InterfaceHelper : public virtual Interface
{
 virtual void a();
 virtual void b();
};

struct DerivedInterfaceImplementation : 
   public virtual DerivedInterface,
   protected InterfaceHelper
{
 virtual c();
};

and expects that those are called in DerivedInterfaceImplementation,
instead of the overrides from InterfaceHelper. 

Admittedly, this language feature _is_ dangerous when using multiple,
virtual inheritance with concrete classes (instead of interfaces, as
in my idiom), because then, figuring out by hand which method wins can
get quite involved. But I don't think we do that now, and we certainly
shouldn't do that for new code (since there are far more pitfalls with
that than this one).

Cheers,

-- 

Thorsten

If you're not failing some of the time, you're not trying hard enough.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to