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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,9a0ff0bffdf63657 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public X-Google-Thread: f43e6,9a0ff0bffdf63657 X-Google-Attributes: gidf43e6,public X-Google-Thread: 1108a1,9a0ff0bffdf63657 X-Google-Attributes: gid1108a1,public From: doylep@ecf.toronto.edu (Patrick Doyle) Subject: Re: Software landmines (loops) Date: 1998/09/01 Message-ID: #1/1 X-Deja-AN: 386985487 X-Nntp-Posting-Host: spark19.ecf Sender: news@ecf.toronto.edu (News Administrator) References: <35f51e53.48044143@ Organization: University of Toronto, Engineering Computing Facility Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Date: 1998-09-01T00:00:00+00:00 List-Id: In article <35EC1590.D50DB8F6@tisny.com>, Mike Spille wrote: > >Would your average programmer ask the question "Where will the loop >terminate?", or "What does the function do?". I think the latter >question is alot more important. I personally subscribe to >the technique of "bailing-out" as soon as possible in a function. Importance is a pretty nebulous concept, but I think there are situations where both questions are asked. "I want this thing to print a message when it's finished doing xxx; where will the loop terminate?..." As for bailing out early in a function, that is the hallmark of defensive programming, which is considered by some (Bertrand Meyer, in particular) to be a harmful practice in large-scale software development. Defensive programming is necesssary at the boundaries of the system, but a system should not be designed to be internally defensive with respect to itself. >This has two effects: nesting later on is greatly reduced (I find >if-else nesting affects readability), and the early-bailouts give >me guarantees later in the code that I don't need to check for. Well, Design By Contract gives the same guarantees without the extra code for checking the conditions. This means that not only do you have no nesting problem, but in a release build, with assertions disabled, you also have no runtime overhead. -PD -- -- Patrick Doyle doylep@ecf.toronto.edu