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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d927b7ea9b65580a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-17 17:44:49 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!207.217.77.102!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!harp.news.atl.earthlink.net!not-for-mail From: Richard Riehle Newsgroups: comp.lang.ada Subject: ;Re: Style: always declare subrountines? Date: Sun, 17 Nov 2002 17:52:13 -0800 Organization: AdaWorks Software Engineering Message-ID: <3DD847CD.A3D78EE9@adaworks.com> References: <3dccc023$0$304$bed64819@news.gradwell.net> Reply-To: richard@adaworks.com NNTP-Posting-Host: 41.b2.40.49 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 18 Nov 2002 01:44:49 GMT X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:31018 Date: 2002-11-18T01:44:49+00:00 List-Id: Victor Porton wrote: > How do you consider this: > > If one would always declare every subrountine of a package body in the > specification (in the public or in the private part) this excludes the > possibility that one may mistakedly create an internal subrountine with > the same specification as a not yet implemented public procedure and > forget to implement this public procedure and so get wrong program > behavior. My own own preference for internal subprograms that have no entry in the specification to promote them to a private package specification. This promotes reuse, enhances maintenance, and allows extensibility. For example, consider: package P1 is procedure Q ... procedure R ... function S return ... end P1; package body P1 is function T ... return ... is ... end T; function Z ... return ... is ... end Z; function W ... return ... is ... end W; procedure Q ... is ... end Q; procedure R ... is ... end R; function S ... return ... is ... end S; end P1; The three functions, T, Z, and W can be promoted to a private package specification, private package P1.Utilities is function T ... return ... ; function Z ... return ... ; function W ... return ... ; end P1.Utilities; Now package body for P1 is as before but, with P1.Utilities; package body P1 is ... end P1; For some reason, we continue to see some designers miss out on the potential for decomposing their systems so they can make the best use of private child library units. The fundamental design policy can be stated as: only include in package body the code corresponding directly to entries in the specification. Everything else should have its own specification and implementation. Richard Riehle