comp.lang.ada
 help / color / mirror / Atom feed
From: "kevin  cline" <kevin.cline@gmail.com>
Subject: Re: OO vs procedural
Date: 4 May 2006 12:40:50 -0700
Date: 2006-05-04T12:40:50-07:00	[thread overview]
Message-ID: <1146771650.465144.99370@g10g2000cwb.googlegroups.com> (raw)
In-Reply-To: <op.s8n079x55afhvo@dogen>

In the second paper, they give this example:

type Alert is abstract tagged record
  ...
end record;
procedure Handle(A: Alert);

type Flaps_Alert is new Alert with record
 ...
end record;

procedure Handle(A: Alert) is
begin
  -- Code common to all alerts
  Log(A);
end Handle;

procedure Handle(A: Flaps_Alert) is
begin
  Alert(A).Handle; -- do common processing
  ... -- flaps specific processing
end Handle;

The authors then point out a describe a potential pitfall of this code
-- that a derived type implementation may fail to call the base
implementation.  This is true.  The authors fail to point out that this
possibility could have been prevented by correct base class design.

I also fail to understand why this error is hard to test, but perhaps I
do not understand S3 testing methods.  I would have expected that a
failure of a derived type X_Alert to call the base type Handle method
would have been caught by a unit test of X_Alert, when it was observed
that after calling X_Alert.Handle, no logging occured.

I would also expect that the error would be easily detected through any
formal verification process, since the erroneous Handle method would
not meet the 'Logging occured' postcondition.




  reply	other threads:[~2006-05-04 19:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-27 12:06 OO vs procedural Ed Falis
2006-05-04 19:40 ` kevin  cline [this message]
2006-05-04 20:21   ` Ludovic Brenta
2006-05-05  7:58     ` Dmitry A. Kazakov
2006-05-04 22:14   ` Brian May
2006-05-05  9:18   ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox