Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!husc6!cca!g-rh
From: g-rh@cca.CCA.COM (Richard Harter)
Newsgroups: comp.lang.c
Subject: Re: Writing readable code
Message-ID: <17411@cca.CCA.COM>
Date: Sat, 4-Jul-87 22:33:02 EDT
Article-I.D.: cca.17411
Posted: Sat Jul  4 22:33:02 1987
Date-Received: Sun, 5-Jul-87 03:01:59 EDT
References: <1158@copper.TEK.COM> <6858@auspyr.UUCP> <17171@cca.CCA.COM> <13008@topaz.rutgers.edu> <1571@sfsup.UUCP> <6051@brl-smoke.ARPA>
Reply-To: g-rh@CCA.CCA.COM.UUCP (Richard Harter)
Organization: Computer Corp. of America, Cambridge, MA
Lines: 37
Summary: Dijkstra considered harmful to good coding practice

In article <6051@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes:
>In article <1571@sfsup.UUCP> mpl@sfsup.UUCP writes:
>Some people (Dijkstra and Gries among them) no longer believe that this
>kind of "conservative" test is preferable to the exact test; they base
>this on what it takes to prove an implementation of an algorithm to be
>correct.

	Are you sure that this is what they are saying?  Although I
have strong reserverations about Dijkstra and his theories about programming
he is no dummy.  The argument, I would suppose, is that a "conservative"
test may conceal errors in the code.  This is a well taken point.  But
the cure is to be both "conservative" and "exact".  For example, if a
function is supposed to return either -1 or a non-negative integer then
you should test for

	-1	special return
	<-1	invalid return
	>-1	legitimate return

and robust code will make all three tests.  To test for <0 is to fuse
two different classes of returns.  (People who worry about the cost
of two tests instead of one in these situations end up with code with
mystery bugs in them.)

	Incidentally, my objection to Dijkstra et. al., is just in
this conception of code as an implementation of an algorithm.  In my
experience, algorithms, once you have a stock of them under your belt
are a minor element in software generation.  Coding an algorithm is
simple (usually -- I grant that there are some hairy ones.)  You can
use black box techniques and treat them in isolation.  The important
part in design and implementation is the system specification, structure,
and control.  Algorithms are just parts on the inventory shelf.

-- 

Richard Harter, SMDS Inc. [Disclaimers not permitted by company policy.]
			  [I set company policy.]