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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Type naming conventions: Any_Foo Date: Sat, 7 Dec 2019 14:36:51 +0200 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net Nx1khVs/ZDZXSdHYAv0s7AtwayfXEpI8qe5+Lp49uBU81NZZIo Cancel-Lock: sha1:E6C4DL+qDb5QCz3TXfPKujjokBM= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 In-Reply-To: Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:57688 Date: 2019-12-07T14:36:51+02:00 List-Id: On 2019-12-07 12:28, Jeffrey R. Carter wrote: > On 12/7/19 1:57 AM, Randy Brukardt wrote: >> >> Agreed. Ada.Containers all have a function Element that retrieves a (copy >> of) a single element object from the container. If the type was named >> element, what would this function be called? Similarly, some of the >> parameters are called Element (thus, Element : Element_Type in many >> parameter lists); those also would need alternate names. > > At a conference long ago (probably in the Ada-83 days), a presenter > claimed that well designed Ada has 90% of its operations named Put or > Get. Horror. The result of blind OO convention :-) > Get is an appropriate name for such an operation. I follow the convention that procedure names are verbs ("Get") or verb phrases ("Remove_Last_Item") that describe the action or its effects, while function names are nouns ("Element") or noun phrases ("Largest_Element") that describe the value returned by the function. Therefore, IMO, "Get" is not a proper name for a function (unless the program models animal breeding, and the Get function returns all the offspring of a particular animal or pair of animals). > More specifically, good names may depend on the data structure. When the > normal Get operation modifies the structure, as for queues and stacks, > Peek is a good name. For stacks, Push and Pop. For queues, Enqueue and Dequeue. Functions should usually not modify their parameter structures; I use procedures for that. > Value is a good name for most other cases. Sometimes, but often it is too general. And it it ambiguous, because it can also mean "worth" or "usefulness". -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .