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,2c6139ce13be9980 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,3d3f20d31be1c33a X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,2c6139ce13be9980 X-Google-Attributes: gid1108a1,public X-Google-Thread: f43e6,2c6139ce13be9980 X-Google-Attributes: gidf43e6,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Interface/Implementation (was Re: Design by Contract) Date: 1997/09/10 Message-ID: #1/1 X-Deja-AN: 271300720 Sender: news@inmet.camb.inmet.com (USENET news) References: Followup-To: comp.object,comp.software-eng,comp.lang.ada,comp.lang.eiffel X-Nntp-Posting-Host: houdini.camb.inmet.com Organization: Intermetrics, Inc. Newsgroups: comp.object,comp.software-eng,comp.lang.ada,comp.lang.eiffel Date: 1997-09-10T00:00:00+00:00 List-Id: Don Harrison (nospam@thanks.com.au) wrote: : ... : 1) The most important reason is that compulsory backward references force : the developer to order everything (apart from things defined in the spec) : from low level to high level. This is the exact opposite of what a human : reader needs to comprehend the body in a linear top-down pass. It's far easier : for them if high level stuff is declared first and low level implementation : detail progressively lower down. That way, they can readily grasp the high : level picture at a more abstract level and, if they require more detail, they : can read on. This may be a practice-versus-capability issue again. There is nothing precluding the use of separate declarations, even if the subprogram is local to the body. One typical coding style adopted for Ada package bodies is: Given this style, the bodies can be ordered in any way that is convenient. : This is why Eiffel classes usually have exported features at the top and : private ones at the bottom. You might expect to see primary ordering on : the basis of functionality and secondary ordering from high level to low : level. : Due to Ada's dependency ordering, I often find myself reading package bodies : in reverse order. You might recommend that your programmers adopt the above style. : 2) It's problematic when an exported feature is removed from the spec (perhaps : because it's erroneously exported) and you have to re-order the body to : accomodate dependencies. If you're not the author of the body, you have to : work out the particular scheme used and find an appropriate spot for it. : This may not be straighforward and is also likely to cause a ripple effect : because operations the operation itself depends on may subsequently have to : move. I find the trial-and-error nature of this activity incredibly annoying. This can certainly be accommodated by putting the separate declaration at the top of the body when it is removed from the spec. There is really no need to reorder. Here is where a common coding convention could really help. It may be that experience with Pascal would tend to think of separate declarations as the exception, rather than the rule, but there is no reason for that view in Ada. In Pascal, having a separate "forward" declaration was somewhat disruptive, because the parameter profile then disappeared from the body, which I at least found hindered readability of the body. : ... : Don. (Reverse to reply) : =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- : Don Harrison au.com.csa.syd@donh -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA