comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Vocabulary matter: Component vs Element vs Item
Date: Thu, 25 Jul 2013 22:12:12 +0200
Date: 2013-07-25T22:12:12+02:00	[thread overview]
Message-ID: <op.w0snqmf0ule2fv@cardamome> (raw)
In-Reply-To: ly7ggetqel.fsf@pushface.org

Le Thu, 25 Jul 2013 21:01:38 +0200, Simon Wright <simon@pushface.org> a  
écrit:

> "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr> writes:
>
>> All three words "component", "element" and "item" could be seen as
>> interchangeable in plain English (or am I wrong?).
>
> I have a feeling that in English (BrE) "component" and "element" are
> more-or-less synonymous, but "item" isn't. "The solution to the problem
> has five Xs" - X could be component or element, but not item; an item is
> a thing on its own, whereas a component or an element is one of many.

Sounds correct.

> So I think that the Ada Containers match this notion: a container can
> have elements (of element_type, eeew), and you replace one of them by an
> item.
>
> I see that the Booch Components have this the other way round:
>
>    procedure Insert (C : in out Abstract_Collection; Elem : Item)
>    is abstract;

After your note above, I now less feel it's an issue to mix both in a same  
domain (or package, to speak Ada). Remains the case you point with the  
swapped choice made in the Booch Components.

May be a way to solve it, is to have an Element_Type which is a subtype  
(as a type aliasing) of Item_Type. This would allow to have both mixed  
case while having consistency between an argument name and its type (there  
are cases where it's better to simply name a thing after its type).

Would look like this sample:


     type Instance_Type is …;
     type Index_Type is …;


     type Item_Type is …;
     subtype Element_Type is Item_Type;

     -- Item_Type is defined first and
     -- Element_Type is a subtype of it,
     -- because Item_Type is defined
     -- independently of what will hold
     -- it. It exists as an item before
     -- it can become an element.


     procedure Append
       (Target : in out Instance_Type;
        Element : Element_Type);

     -- To the object receiving it,
     -- and which will hold it,
     -- it's an element.


     function Item
       (This : Instance_Type;
        I : Index_Type)
        return Item_Type;

     -- To the client receiving it,
     -- and which will hold it,
     -- it's first an item (may
     -- become an element later
     -- to it too).


Looks OK to me as I look at it. I believe I will opt for this convention.

Thanks for your not Simon. And Jeffrey too :-P (for the idea to look  
somewhere else)


-- 
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University


  parent reply	other threads:[~2013-07-25 20:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-25 16:38 Vocabulary matter: Component vs Element vs Item Yannick Duchêne (Hibou57)
2013-07-25 19:01 ` Simon Wright
2013-07-25 19:29   ` Jeffrey Carter
2013-07-25 20:12   ` Yannick Duchêne (Hibou57) [this message]
2013-07-26  7:59     ` Simon Wright
2013-07-26 18:42       ` Yannick Duchêne (Hibou57)
2013-07-26 18:53         ` Yannick Duchêne (Hibou57)
2013-07-26 19:29         ` Yannick Duchêne (Hibou57)
2013-07-27  3:42           ` Randy Brukardt
2013-07-27  8:18         ` Simon Wright
2013-07-27  3:35       ` Randy Brukardt
2013-07-27 15:57         ` Shark8
2013-07-26  9:56 ` Manuel Collado
2013-07-26 17:24 ` Charles H. Sampson
2013-07-26 18:29   ` Adam Beneschan
2013-07-26 19:12     ` Yannick Duchêne (Hibou57)
2013-07-26 19:56       ` Adam Beneschan
2013-07-29 20:25 ` Eryndlia Mavourneen
2013-07-29 22:30   ` Yannick Duchêne (Hibou57)
2013-07-30 13:46     ` Eryndlia Mavourneen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox