Reputation: 38346
I'm creating a C# library and am going to be prefix most of the public classes with the protocol they use (TCP, UDP, etc) and I came to a little dilemma: should it be TCPXxxx
or TcpXxxx
?
There doesn't seem to be a standard in the .NET framework (IPAddress
versus TcpClient
).
Which you would prefer when working with a library: TCPXxxx
or TcpXxxx
?
Upvotes: 2
Views: 1864
Reputation: 564433
It should be TcpXxxx, by the design guidelines.
In the design guidelines, 2 letter acronyms are capitalized, all others are pascal cased.
From Framework Design Guidelines by Cwalina and Abrams:
- Do capitalize both charaters of two-character acronyms, exception the first word of a camel-cased identifier.
System.IO public void StartIO(Stream ioStream)
- Do capitalize only the first character of acronyms with three or more characters, except the first word of a camel cased identifier.
MSDN has an abbrieviated, shorter version of this.
Upvotes: 9
Reputation: 3205
I know in eclipse I can quickly specify a type by using just the capitals letters of the type name so I prefer to under-capitalise rather than over-capitalise... I don't know if VS can do the same but it is fan-tastic.
Upvotes: 0
Reputation: 1354
I know this is C# coding style but I prefer the Python PEP 8 Style
Note: When using abbreviations in CapWords, capitalize all the letters of the abbreviation. Thus HTTPServerError is better than HttpServerError.
But when in Rome...consistent code is better which is why language style guides are a good idea.
Upvotes: 0
Reputation: 829
You might consider putting these classes in a namespace called "TCP". If you do so, then your function/class names in that namespace will get shorter and clearer and you won't have to worry about this issue at all.
Upvotes: 0
Reputation: 141
I always like to imagine a theoretical process that converts WordsLikeThis to words-like-this, and imagine how the name in question would convert. Some examples:
TCPSocket -> t-c-p-socket
TcpSocket -> tcp-socket
Clearly the latter makes more sense.
Upvotes: 2
Reputation: 30934
Generally, when it's a 2-character prefix, leave it uppercase (IPAddress) and when it's 3 characters or more, Pascal-case the prefix (TcpXxxx).
There are a few exceptions to this rule (e.g., if a prefix is a proper name that's uppercase).
Upvotes: 1