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=0.5 required=5.0 tests=BAYES_05,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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!postnews.google.com!g10g2000cwb.googlegroups.com!not-for-mail From: "kevin cline" Newsgroups: comp.lang.ada Subject: Re: OO vs procedural Date: 4 May 2006 12:40:50 -0700 Organization: http://groups.google.com Message-ID: <1146771650.465144.99370@g10g2000cwb.googlegroups.com> References: NNTP-Posting-Host: 208.8.57.2 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1146771656 6745 127.0.0.1 (4 May 2006 19:40:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 4 May 2006 19:40:56 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 ics_server.swacorp.com (ICS 2.3.0.0.16) Complaints-To: groups-abuse@google.com Injection-Info: g10g2000cwb.googlegroups.com; posting-host=208.8.57.2; posting-account=Thx6EwwAAAAirqf96i7UdETSL0vfyj5f Xref: g2news2.google.com comp.lang.ada:4076 Date: 2006-05-04T12:40:50-07:00 List-Id: 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.