Suffix _T for types found good

This is a discussion on Suffix _T for types found good within the ADA forums in Programming Languages category; I just want to offer my experience on the old issue of adding a suffix _T to all type names. In my experience it is good. In a large (50KLOC) industrial experience of analysing Ada 95 source (written by others) this convention clearly helped understanding the source and writing test cases. This was a team work. I started using the convention in the personal process also, and also experienced improvement. In the personal process, I particularly like that: (1) I don't have to think up "good" type names that sometimes simply do not exist; too often it is very difficult ...

Go Back   Application Development Forum > Programming Languages > ADA

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-06-2008, 10:58 AM
amado.alves@gmail.com
Guest
 
Default Suffix _T for types found good

I just want to offer my experience on the old issue of adding a suffix
_T to all type names.

In my experience it is good.

In a large (50KLOC) industrial experience of analysing Ada 95 source
(written by others) this convention clearly helped understanding the
source and writing test cases. This was a team work.

I started using the convention in the personal process also, and also
experienced improvement. In the personal process, I particularly like
that:

(1) I don't have to think up "good" type names that sometimes simply
do not exist; too often it is very difficult or impossible to come up
with a good pattern of names for the type, the object, the array,
etc.; with _T at least one term is removed from the equation

(2) I can promptly write things like

Index : Index_T;
procedure Proc (Index : Index_T);
etc.

For access types I have been writing _Ptr_T but I'm not 100% happy.

Regarding "_T" vs. "_Type" I am convinced the former is better but I
have to leave the advocacy for later. Or for others ;-)
Reply With Quote
  #2  
Old 08-06-2008, 12:34 PM
Peter C. Chapin
Guest
 
Default Re: Suffix _T for types found good

amado.alves@gmail.com wrote:

> Regarding "_T" vs. "_Type" I am convinced the former is better but I
> have to leave the advocacy for later. Or for others ;-)


Personally I prefer _Type. Yes it is more verbose but it follows the
convention of using fully spelled out words for things. For access types
I have used _Pointer. As in

type Integer_Pointer is access all Integer;

It mostly seems to work for me.
Reply With Quote
  #3  
Old 08-06-2008, 01:18 PM
Niklas Holsti
Guest
 
Default Re: Suffix _T for types found good

amado.alves@gmail.com wrote:
> I just want to offer my experience on the old issue of adding a suffix
> _T to all type names.
>
> In my experience it is good.


I agree.

> For access types I have been writing _Ptr_T but I'm not 100% happy.


I use _Ref (instead of _T) for access types. To remind me of
"reference semantics".

--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
Reply With Quote
  #4  
Old 08-06-2008, 01:23 PM
amado.alves@gmail.com
Guest
 
Default Re: Suffix _T for types found good

On 6 Ago, 17:34, "Peter C. Chapin" <pcc482...@gmail.com> wrote:
> amado.al...@gmail.com wrote:
> > Regarding "_T" vs. "_Type" I am convinced the former is better but I
> > have to leave the advocacy for later. Or for others ;-)

>
> Personally I prefer _Type. Yes it is more verbose but it follows the
> convention of using fully spelled out words for things.


But this is not really a thing, it's a suffix :-)

> For access types
> I have used _Pointer. As in
>
> * * * * type Integer_Pointer is access all Integer;
>
> It mostly seems to work for me.


Here I am more militant. It must end in _T or _Type also. Otherwise
you loose the advantages e.g. you cannot write

Integer_Pointer : Integer_Pointer_T;

And this is also one reason why I prefer _T to _Type (and Ptr to
Pointer): because _Pointer_Type (or even _Ptr_Type) is just too long a
suffix.

(This is one case where abbreviations are acceptable. IIRC even the
Guidelines 95 accept exceptions to the long names rule. The industry
abuses this with their way too many and unecessary 3-letter acronyms,
but this is an acceptable case.)

But this is for the application types (_T). More in house style. For
libraries I think I'd rather see _Type. More conventional. But still,
a suffix.

And in sum, whatever the form, it's good to see that more Adaists are
suffixists :-)
Reply With Quote
  #5  
Old 08-06-2008, 01:57 PM
amado.alves@gmail.com
Guest
 
Default Re: Suffix _T for types found good

"_Ref_T" has the right size :-)

But it's got to have the _T. I want to write

Object_Ref : Object_Ref_T;
Reply With Quote
  #6  
Old 08-06-2008, 02:43 PM
Niklas Holsti
Guest
 
Default Re: Suffix _T for types found good

amado.alves@gmail.com wrote:
> "_Ref_T" has the right size :-)
>
> But it's got to have the _T. I want to write
>
> Object_Ref : Object_Ref_T;


I use a lot of private types, not visibly of an access type, but
privately defined as an access to a type defined in the body of the
package. I want to hide, to some extent, the fact that the type is
implemented as an access type, so I don't use _Ref on the object
identifiers. Nearly all uses of identifiers for such objects occur
as formal or actual parameters; the only reason that I use _Ref on
the type-name, instead of _T, is to explain why the parameter mode
is nearly always "in", although the parameter may be modified:

procedure Foo (Object : in Object_Ref) ...

Using _Ref on the object identifiers would reduce readability in my
opinion -- the many _Refs would clutter the statements, and not
only the declarations. I treat the _Ref suffix as reserved for
access types.

--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
Reply With Quote
  #7  
Old 08-06-2008, 03:11 PM
Jeffrey R. Carter
Guest
 
Default Re: Suffix _T for types found good

amado.alves@gmail.com wrote:
> I just want to offer my experience on the old issue of adding a suffix
> _T to all type names.
>
> In my experience it is good.


I disagree. _T[ype] adds no value. Consider your examples:

> Index : Index_T;
> procedure Proc (Index : Index_T);


It is clear without the suffix that the identifiers are types.

Making the effort to come up with good names is an important part of SW
engineering. _T[ype] is an excuse for not thinking.

I use a number of suffices for type names to allow using the best name for
objects and parameters, while still adding value to the type name:

Numeric types: _Value, _Index, (rarely) _Range
Enumeration types (and numeric types used as IDs): _ID, _Name
Access types: _Ptr, _Handle
Private types: _Handle
Array types: _Set, _List
Record types: _Info, _Data, _Group

These suffixes provide information about the kind of type and its intended
usage. Of course, when a better name exists, it should be used rather than
unthinkingly using one of these.

On a large project with multiple developers this approach proved to be easy to
use and understand.

--
Jeff Carter
"Sheriff murdered, crops burned, stores looted,
people stampeded, and cattle raped."
Blazing Saddles
35
Reply With Quote
  #8  
Old 08-06-2008, 03:16 PM
amado.alves@gmail.com
Guest
 
Default Re: Suffix _T for types found good

> Numeric types: _Value, _Index, (rarely) _Range
> Enumeration types (and numeric types used as IDs): _ID, _Name
> Access types: _Ptr, _Handle
> Private types: _Handle
> Array types: _Set, _List
> Record types: _Info, _Data, _Group


These are wonderful afixes, thanks for sharing, I use similar afixes
myself personaly and on teams. Only, I still add _T, so I can write

Object_Value : Object_Value_T;
Reply With Quote
  #9  
Old 08-06-2008, 03:36 PM
amado.alves@gmail.com
Guest
 
Default Re: Suffix _T for types found good

> > Object_Ref : Object_Ref_T;
....
> Using _Ref on the object identifiers would reduce readability in my
> opinion -- the many _Refs would clutter the statements...


Yes, this is only for cases where you have a value and a pointer in
the same block of logic e.g.

...
Object_Ref : Object_Ref_T;
Object : Object_T;
Thing_Ref : Thing_Ref_T;
Thing : Thing_T;
declare
Object_Ref := Complicated_Logic_To_Find_An_Access_Type;
Object := Object_Ref.all;
X := Logic_Not_Dependent_On_The_Address (Object);
-- similarly for Thing
Y := Logic_Not_Dependent_On_The_Address (Thing);
Z := Logic_Not_Dependent_On_The_Addresses (Object, Thing);
-- and so on and so on
Reply With Quote
  #10  
Old 08-06-2008, 03:47 PM
Jeffrey R. Carter
Guest
 
Default Re: Suffix _T for types found good

amado.alves@gmail.com wrote:
>
> Object_Value : Object_Value_T;


If I have a type Object_Value, it's because the best object/parameter name is
not Object_Value. If the best name is Object_Value, then there is still a better
type name than unthinkingly appending _T to the best name.

Obviously this is a contrived example, but _Value is usually not the best choice
for an object/parameter name.

--
Jeff Carter
"Sheriff murdered, crops burned, stores looted,
people stampeded, and cattle raped."
Blazing Saddles
35
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 09:44 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.