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=2.2 required=5.0 tests=BAYES_00,INVALID_MSGID, PDS_OTHER_BAD_TLD,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: Loryn Jenkins Subject: Re: Software landmines (loops) Date: 1998/09/03 Message-ID: <35EE5BB7.4430C8EA@s054.aone.net.au>#1/1 X-Deja-AN: 387423935 Content-Transfer-Encoding: 7bit References: <6silt4$gb0@flatland.dimensional.com> <9qnQhDAAvZ71EwAx@radm.demon.co.uk> <6skh4n$491@flatland.dimensional.com> X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii X-Trace: news.mel.aone.net.au 904813588 26261 203.12.186.142 (3 Sep 1998 09:06:28 GMT) Organization: TekRite Pty Ltd Mime-Version: 1.0 Reply-To: loryn@acm.org NNTP-Posting-Date: 3 Sep 1998 09:06:28 GMT Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Date: 1998-09-03T09:06:28+00:00 List-Id: > if L.Top /= R.Top then > return False; > end if; Jim Cochrane is right: this precondition comment was discussing the C++ fragment from Robert Martin. However, to help historians here, I didn't misinterpret your code as a precondition. I misinterpreted it as checking the first item on the stack (you know, the stuff at the `top'). Hence, given those semantics, I thought it necessary to add the precondition l.count = r.count However, addressing Richard Melvin's comment that this is an abuse of DBC, I actually don't agree. While, as Jim Cochrane says, it is better to think through the required preconditions and the desired postcondition, and determine exactly what the routine needs to do, it is still *good* practise to document *requirements of the actual routine* (even if they are less than satisfactory). That way, client programmers have a chance to decide: (i) exactly what to check before using the routine (ii) whether they want to use the routine at all. I'll give you an example: Pylon is a small, lightweight and portable data structure library written in Eiffel. It has some pretty interesting, well designed features. However, one of the features I disliked was the insertion procedure on SETs. Among other preconditions, it required: not_in_set: not has (v) --where v is the input argument Now, for a SET class, I thought that this was an unreasonable request. (Isn't it part of this container's job to handle SETness, as opposed to BAGness?) I was able to determine the exact behaviour extremely efficiently, thanks to this documentation. I was also able to determine that ISE's open source data structure library, EiffelBase, handled insertion to the SET as I would've expected. Loryn Jenkins