From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Type naming conventions: Any_Foo
Date: Sat, 7 Dec 2019 14:36:51 +0200
Date: 2019-12-07T14:36:51+02:00 [thread overview]
Message-ID: <h51kn3F9rctU1@mid.individual.net> (raw)
In-Reply-To: <qsfurh$mtn$1@dont-email.me>
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
. @ .
next prev parent reply other threads:[~2019-12-07 12:36 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-04 13:56 Type naming conventions: Any_Foo Alejandro R. Mosteo
2019-12-04 14:52 ` Lucretia
2019-12-04 16:42 ` Alejandro R. Mosteo
2019-12-05 10:51 ` AdaMagica
2019-12-05 17:27 ` Jeffrey R. Carter
2019-12-05 17:45 ` Dmitry A. Kazakov
2019-12-05 20:03 ` Jeffrey R. Carter
2019-12-05 21:51 ` Dmitry A. Kazakov
2019-12-05 23:12 ` Randy Brukardt
2019-12-06 20:20 ` Jeffrey R. Carter
2019-12-07 1:19 ` Randy Brukardt
2019-12-06 20:18 ` Jeffrey R. Carter
2019-12-06 20:35 ` Dmitry A. Kazakov
2019-12-07 0:57 ` Randy Brukardt
2019-12-07 10:28 ` Jeffrey R. Carter
2019-12-07 12:36 ` Niklas Holsti [this message]
2019-12-08 12:04 ` Jeffrey R. Carter
2019-12-07 10:13 ` Jeffrey R. Carter
2019-12-07 11:21 ` Dmitry A. Kazakov
2019-12-08 11:55 ` Jeffrey R. Carter
2019-12-08 12:38 ` Dmitry A. Kazakov
2019-12-08 14:31 ` Shark8
2019-12-08 21:58 ` Jeffrey R. Carter
2019-12-09 22:47 ` Shark8
2019-12-07 23:24 ` Jere
2019-12-08 12:14 ` Jeffrey R. Carter
2019-12-09 22:07 ` Randy Brukardt
2019-12-05 19:49 ` Niklas Holsti
2019-12-05 20:47 ` Jeffrey R. Carter
2019-12-05 21:33 ` Niklas Holsti
2019-12-06 11:44 ` Lucretia
2019-12-06 20:23 ` Jeffrey R. Carter
2019-12-06 20:11 ` Jeffrey R. Carter
2019-12-06 20:46 ` Dmitry A. Kazakov
2019-12-06 21:55 ` Niklas Holsti
2019-12-07 10:19 ` Jeffrey R. Carter
2019-12-07 12:05 ` Niklas Holsti
2019-12-08 11:59 ` Jeffrey R. Carter
2019-12-06 8:57 ` AdaMagica
2019-12-06 9:55 ` J-P. Rosen
2019-12-06 15:30 ` Optikos
2019-12-07 3:34 ` Shark8
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox