473,385 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Generic Class Naming Convention


I've noticed alot of people tacking on a "T" for a generic abled version of
an older class.

Ex:

1.1 Code

IDataStore
I take it, and while I keep IDataStore around for 2.0 version, I decide to
make a Generic version.

So I see this:

IDataStoreT < T >
Is that something that just developed? Or does it (the naming convention)
come from somewhere?
I've got Brad Abrams book here (Framework Design Guidelines) and it doesn't
speak to the classname specifically, only the parameter type <T>.
Thanks.
Aug 13 '07 #1
5 2149


"Bob Powell [MVP]" <bo*@spamkillerbobpowell.netwrote in message
news:15**********************************@microsof t.com...
>I would keep away from such naming. It's not necessary because the template
syntax and signatures are totlly different to those of the straight classes
and such indicative naming schemes are frowned upon, probably because the
schemes change so often that code that uses them can become either
unreadable or confusuing when modifications to the convention orrur.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

I'm still using .Net 2003 :)

Say you have your own class named "Collection". Can you create a new type
under the same namespace with the same name for a generic, "Collection<T>"?
If not (and Collection was an actual named class that described both
completely with the exception of one is generic), what would you name the
"New" generic "Collection<T>"?

Thanks,
Mythran
Aug 13 '07 #2


"Mythran" <ki********@hotmail.comwrote in message
news:43**********************************@microsof t.com...
>

"Bob Powell [MVP]" <bo*@spamkillerbobpowell.netwrote in message
news:15**********************************@microsof t.com...
>>I would keep away from such naming. It's not necessary because the
template syntax and signatures are totlly different to those of the
straight classes and such indicative naming schemes are frowned upon,
probably because the schemes change so often that code that uses them can
become either unreadable or confusuing when modifications to the
convention orrur.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing


I'm still using .Net 2003 :)

Say you have your own class named "Collection". Can you create a new type
under the same namespace with the same name for a generic,
"Collection<T>"? If not (and Collection was an actual named class that
described both completely with the exception of one is generic), what
would you name the "New" generic "Collection<T>"?

Thanks,
Mythran

Nevermind, I think. I believe Jon answered my question in his reply about 2
minutes after my message lol.

Mythran
Aug 13 '07 #3
Mythran wrote:
Say you have your own class named "Collection". Can you create a new
type under the same namespace with the same name for a generic,
"Collection<T>"? If not (and Collection was an actual named class that
described both completely with the exception of one is generic), what
would you name the "New" generic "Collection<T>"?
Yes, this works fine:

namespace Foo
{
public class Collection { }
public class Collection<T{ }
public class Collection<T1,T2{ }
}

So there's no need to name the generic ones CollectionT<T>. (And what
would you name the second generic one above anyhow? CollectionTT?)

--
-glenn-
Aug 13 '07 #4
Mythran <ki********@hotmail.comwrote:
Say you have your own class named "Collection". Can you create a new type
under the same namespace with the same name for a generic, "Collection<T>"?
Yes, you can. Indeed, the System namespace in .NET 2.0 has the
Nullable<Tstruct and the Nullable class.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 13 '07 #5
Mythran <ki********@hotmail.comwrote:
Nevermind, I think. I believe Jon answered my question in his reply about 2
minutes after my message lol.
But hey, that hasn't stopped me from answering it again ;)

(Note to self: read all messages before starting to reply...)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 13 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Sandeep Sharma | last post by:
For many years I have been following the convention of naming all class attributes with a leading underscore. This enables me to quickly identify the class attributes when I encounter them in the...
27
by: Derek | last post by:
The company where I work uses a naming convention that I have never used before. They use mixed-case letters for public member functions, but lower-case with underscores for the rest, like this:...
8
by: Ares Lagae | last post by:
When adopting the coding style of the standard C++ library, you often run into naming problems because class names are lower case, and member functions do not have get/set prefixes. For example:...
48
by: mahurshi | last post by:
I am new to c++ classes. I defined this "cDie" class that would return a value between 1 and 6 (inclusive) It runs fine and gives no warnings during compilation. I was wondering if you guys...
114
by: Jonathan Wood | last post by:
I was just wondering what naming convention most of you use for class variables. Underscore, "m_" prefix, camel case, capitalized, etc? Has one style emerged as the most popular? Thanks for...
9
by: mps | last post by:
I want to define a class that has a generic parameter that is itself a generic class. For example, if I have a generic IQueue<Tinterface, and class A wants to make use of a generic class that...
7
by: beginner | last post by:
Hi Everyone, I have encountered a small problems. How to call module functions inside class instance functions? For example, calling func1 in func2 resulted in a compiling error. "my module...
0
by: sloan | last post by:
Is anyone else using the Microsoft Practices EnterpriseLibrary conventions for naming FILES (.cs) as far as a non-generic and generic implementation is concerned? Anyone have an alternative? ...
23
by: mike3 | last post by:
Hi. (posted to both newsgroups since I was not sure of which would be appropriate for this question or how specific to the given language it is. If one of them is inappropriate, just don't send...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.