Re: OT: CoolIris releases PicLens 1.6 for Firefox Mac & Win
- From: "Danny Thorpe" <danny@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: 15 Jan 2008 20:06:06 -0700
Captain Jake wrote:
Interesting comments on C++, a language I've always liked more than
most of the Delphi community does. Would you care to expand
on/demonstrate the points you made above about C++, by any chance?
Sure. Let's take the C++ semantics of "virtual" as an example.
class A {
public:
virtual int foo(int i);
}
class B: public A {
int foo(int i);
}
Class B inherits from A and overrides the virtual method foo introduced
in A.
Now then. Time passes. Eventually someone comes along and modifies
the base class. There are multiple avenues of silent failure that C++
will not alert you to.
First, what if Foo is deleted from the base class? B::foo is no longer
overriding the base class method, it's just introducing a new foo
method. Multiply this by a dozen or more descendents of A and you have
a truckload of foo running around that are completely unrelated.
C++ does not distiguish between introducing a new virtual method and
overriding an existing virtual method. For code maintenance over the
long haul, this is a problem. It is very rare that code that was
written to override a base behavior will work correctly if the base
behavior is no longer there. And yet, C++ cannot not flag this as a
compile time error.
The opposite case (method insertion) is also problematic - and more
common than the case above: Let's say B introduces a new virtual
method called Bar. The base class doesn't have a Bar, so there's no
issue. Some time later, however, if someone introduces a Bar into the
base class A, you'll have a problem. If the method Bar added to A
happens to be a virtual method, but the params don't match the Bar
introduced in B, then you'll get a compile error even though
technically the two methods could be maintained independently without
runtime issues. If you're lucky, you'll get a compile time error.
It's when you don't get a compiler error that the real nightmares begin.
This is covered in detail in Chapter 3 of "Delphi Component Design".
-Danny
--
Discover More with CoolIris: http://www.cooliris.com
.
- Follow-Ups:
- Re: OT: CoolIris releases PicLens 1.6 for Firefox Mac & Win
- From: Rudy Velthuis [TeamB]
- Re: OT: CoolIris releases PicLens 1.6 for Firefox Mac & Win
- From: Captain Jake
- Re: OT: CoolIris releases PicLens 1.6 for Firefox Mac & Win
- References:
- OT: CoolIris releases PicLens 1.6 for Firefox Mac & Win
- From: Danny Thorpe
- Re: OT: CoolIris releases PicLens 1.6 for Firefox Mac & Win
- From: Captain Jake
- OT: CoolIris releases PicLens 1.6 for Firefox Mac & Win
- Prev by Date: Re: OT: CoolIris releases PicLens 1.6 for Firefox Mac & Win
- Next by Date: Re: OT: CoolIris releases PicLens 1.6 for Firefox Mac & Win
- Previous by thread: Re: OT: CoolIris releases PicLens 1.6 for Firefox Mac & Win
- Next by thread: Re: OT: CoolIris releases PicLens 1.6 for Firefox Mac & Win
- Index(es):
Relevant Pages
|