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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC 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: Nick Leaton Subject: Re: Software landmines (loops) Date: 1998/09/16 Message-ID: <35FF79D6.3C2725D6@calfp.co.uk>#1/1 X-Deja-AN: 391644535 Content-Transfer-Encoding: 7bit X-NNTP-Posting-Host: calfp.demon.co.uk:158.152.70.168 References: <902934874.2099.0.nnrp-10.c246a717@news.demon.co.uk> <6r1glm$bvh$1@nnrp1.dejanews.com> <6r9f8h$jtm$1@nnrp1.dejanews.com> <6renh8$ga7$1@nnrp1.dejanews.com> <6rf59b$2ud$1@nnrp1.dejanews.com> <6rfra4$rul$1@nnrp1.dejanews.com> <35DBDD24.D003404D@calfp.co.uk> <6sbuod$fra$1@hirame.wwa.com> <35f51e53.48044143@ <904556531.666222@miso.it.uq.edu.au> <6sgror$je8$3@news.indigo.ie> <6sh3qn$9p2$1@hirame.wwa.com> <35EC1B94.CAC23CB3@tisny.com> <6si1rm$649$1@hirame.wwa.com> <35F65BA6.D4709D8A@calfp.co.uk> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 905935375 nnrp-06:20676 NO-IDENT calfp.demon.co.uk:158.152.70.168 MIME-Version: 1.0 Reply-To: nickle@pauillac Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Date: 1998-09-16T00:00:00+00:00 List-Id: Giovanni 8 wrote: > > > nickle wrote: > > So lets say the loop calculates a square root. What should > > "do this" and "do that" do?... Do you want to rewrite square > > root for each case? > > Try for a less simplistic example, please. > > Part of my point is that the called function (Get, in the > example I was following-up to) does its job well, has one > or 2 different kinds of error values, & n "successful" return > values. Get, however, "knows" little of the environment, the > context, from which it is called. That's fine, but it means > that there are things it cannot handle with an eye to that > context. The instant routine, which calls Get, does "know" > that context, and needs to do a number of different things > depending on the results of the Get, some having to do with > error conditions of one sort or another, and others having > to do with "normal" conditions, all to be dealt with in > the context of the current context, in the current function, > in the current loop. But again what if I don't want to know all of the different things? The Get routine assumes that you do want to know all. Design by contract and command query separation makes life much simpler. First, any query doesn't modify the external view of an object. The procedure in your 'get' feature is modifying the object, its doing some work. Splitting it into a procedure to do the work, and a set of queries to examine the results makes life simple. Then you can add preconditions, such as not less than zero in the square root case to make sure that the caller behaves. If they don't then behaviour is undefined, but would raise an exception. Its a bug after all. Sounds hard, but would you expect your program to fix itself? Nick -- Nick