From 2959142501701373959
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ccbfcafab96cf493
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-12-04 11:38:01 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!opentransit.net!proxad.net!news-hub.cableinet.net!blueyonder!diablo.netcom.net.uk!netcom.net.uk!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: pdimov@mmltd.net (Peter Dimov)
Newsgroups: comp.std.c++
Subject: Re: Proposol to increase robustness of programs
Date: Tue,  4 Dec 2001 19:37:11 GMT
Organization: http://groups.google.com/
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <7dc3b1ea.0112040358.1ab543ba@posting.google.com>
References: <3BFE97B3.91430FB1@wanadoo.fr> <T23N7.64$%j1.23498@news11-gui.server.ntli.net> <3C058126.36357A00@acm.org> <7dc3b1ea.0111300954.186f1ff5@posting.google.com> <3C094998.F387ABB1@acm.org>
X-Trace: mail2news.demon.co.uk 1007494636 mail2news:24148 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
NNTP-Posting-Date: 4 Dec 2001 11:58:37 GMT
Lines: 66
Xref: archiver1.google.com comp.std.c++:8462

Pete Becker <petebecker@acm.org> wrote in message news:<3C094998.F387ABB1@acm.org>...
> Peter Dimov wrote:
> > 
> > Pete Becker <petebecker@acm.org> wrote in message news:<3C058126.36357A00@acm.org>...
> > 
> > [override keyword]
> > 
> > > The reason that it doesn't get any support from me is that it solves a
> > > non-problem. If you want to be sure that your member function overrides
> > > a virtual function in the base, write a test case that calls it through
> > > the base. You have to do this anyway, in order to check the behavior of
> > > your derived class. So this error falls out automatically from routine
> > > testing.
> > 
> > You are right. Programmers that use unit tests (group #1) don't need
> > override.
> > 
> > On the other hand, programmers that do not do proper testing (group
> > #2) will benefit from it. The cost will be an extra keyword.
> > 
> > Not giving group #2 what they want will not automatically make them
> > migrate to #1.
> > 
> 
> Giving group #2 what they want won't turn them into good programmers.

Of course. But the definition of a good programmer will change with
the addition of 'override.'

To give an example: making a class abstract is enough, in current C++,
to prevent instantiation. I don't _need_ to test whether the class can
be instantiated, copied, sliced to, because I've already taken care of
this. This probably makes me a bad programmer by your definition, but
I find the tradeoff acceptable.

Similarly, tagging the overrider with 'override' will ensure that a
whole class of errors become the responsibility of the compiler, not
the programmer. The keyword is, in essence, my unit test for the
problem.

This will not prevent anyone from using stricter coding practices. I
fully appreciate the importance of a good unit test; not only that, I
believe that the test should be written not by the original
implementor of the class, but by someone else that doesn't even have
access to the source, but works _only_ by the formal specification of
the interface.

So 'override' does not really compete with a well chosen testing
methodology. The implementor uses 'override' and the tester uses unit
tests.

Incidentally, I do change virtual function signatures, when I can
afford to do so and when this leads to a better design. The tedious
search for overriders that follows is enough to make me a supporter of
'override.'

--
Peter Dimov
Multi Media Ltd.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]



