From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,71fbc59f7794b9af X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mail NNTP-Posting-Date: Thu, 04 May 2006 15:22:01 -0500 From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: OO vs procedural References: <1146771650.465144.99370@g10g2000cwb.googlegroups.com> Date: Thu, 04 May 2006 22:21:37 +0200 Message-ID: <87u085v8vi.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:1UaKtUqMD2yNOFLwsAlWWfdnEkA= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 62.235.55.24 X-Trace: sv3-YFFvgsjSwX0sesFP8kDlsLAD2UcEyB2lJ0/Xt7Nj7y9BCTHMT+FabmQqvKX1fEeV6ZmHAU+HhteOeyw!XQ36+668zePNLhM4qBnfWLXw7oZA/2h+ngQX/2JRYDv55up2WJfbwGKG3fQNJDkF1mmtz20+ X-Complaints-To: abuse@scarlet.be X-DMCA-Complaints-To: abuse@scarlet.biz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:4077 Date: 2006-05-04T22:21:37+02:00 List-Id: "kevin cline" writes: > 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. Of course, what you say is true - good unit testing or good peer review will catch the error, and the formal verification process will document how the error was found, corrected, and verified to be corrected. But, by that argument, "any good programmer with a good process can write perfect software in any language, even assembly language". The point is to help the compiler catch the error automatically, before the first unit test is written and before any peer review takes place. Compile-time checks are why we (in avionics) use Ada in the first place. In other industries, people also like the run-time checks, which help later, i.e. during testing. -- Ludovic Brenta.