what does this text mean that is about generics and naming guidelines

T

Tony Johansson

Hello!

I want to be able to use the correct terminology when talking about
generics.

The text says "If generics are used in the program, it helps when generic
types can be distinguished from non-generic types.
Here are naming guidelines for generic types:

* Generic type names should be prefixed with letter T.
*If generic type can be replaced by any class because there's no special
requirement, and only one generic type is used,
the character T is good as a generic type name."¨

My first question is about terminology. If someone say generic type as is
used in this text what is it supposed that it mean ?
I would say that List<T> is a generic type is that correct terminology ?
But why not say generic class insted of generic type ?

My second question the text says that generic type should be prefix with T
then List<T> should be called TList<T> .

My third question the text say the character T is good as a generic type
name is that actually correct used terminology ?

//Tony
 
J

Jeff Johnson

I want to be able to use the correct terminology when talking about
generics.

The text says "If generics are used in the program, it helps when generic
types can be distinguished from non-generic types.
Here are naming guidelines for generic types:

* Generic type names should be prefixed with letter T.
*If generic type can be replaced by any class because there's no special
requirement, and only one generic type is used,
the character T is good as a generic type name."¨

My first question is about terminology. If someone say generic type as is
used in this text what is it supposed that it mean ?
I would say that List<T> is a generic type is that correct terminology ?
But why not say generic class insted of generic type ?

My second question the text says that generic type should be prefix with T
then List<T> should be called TList<T> .

My third question the text say the character T is good as a generic type
name is that actually correct used terminology ?

I was confused for a moment but then I realized what the text is talking
about. It is referring to the placeholders for a concrete type in the
declaration of a custom generic class (the things that the programmer will
specify later), not the class name itself.

An example is the best way to describe this. Consider Dictionary<TKey,
TValue>. The "generic types" are "TKey" and "TValue", NOT "Dictionary." This
is where the T prefix is being recommended.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top