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: 1108a1,9a0ff0bffdf63657 X-Google-Attributes: gid1108a1,public X-Google-Thread: f43e6,9a0ff0bffdf63657 X-Google-Attributes: gidf43e6,public From: behrends@cse.msu.edu (Reimer Behrends) Subject: Re: Software landmines (loops) Date: 1998/09/17 Message-ID: #1/1 X-Deja-AN: 391984953 References: <35f51e53.480 <904556531.66622 Organization: Michigan State University Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Date: 1998-09-17T00:00:00+00:00 List-Id: Anybody got a suggestion what a reasonable value for Followup-To would be for this? Matthew Heaney (matthew_heaney@acm.org) wrote: [...] > Robert Martin argued against early returns (or middle-exit loops) by > stating that you might forget to release a resource, if you return > early. Or more generally, to reestablish a predicate that has been temporarily violated. > I gave the counter-example that the resource management problem should > be solved another way, by using a deconstructor (C++) or a controlled > type (Ada95). I based my arguement on the fact that this is what you > should do no matter what, because of the presence of exceptions. > > Stroustrup calls this idiom "resource acquistion is initialization." It should, however, be noted that there are those who as a general rule don't use exceptions at all, with the obvious benefits alluded to by Robert Martin. Also, using single-entry/single-exit in such a strict fashion allows you to view _any_ code block as an abstract unit, with the added benefit that you can decompose and restructure complex code almost at will. Reimer Behrends