Microsoft naming conventions for .Net put constants in Pascal Case. In fact, it explicitly tells us to avoid using all caps for constants:
You might also have to capitalize identifiers to maintain compatibility with existing, unmanaged symbol schemes, where all uppercase characters are often used for enumerations and constant values. In general, these symbols should not be visible outside of the assembly that uses them.
From MSDN.
On SO I found some questions on the subject, like this one, but I couldn't find a rationale. So, anyone know or have a reference that points to why MS chose this convention?
C# convention is not to use uppercase for constants.
Symbolic constant names are commonly written in upper case so they can be readily distinguished from lower case variable names. In many ways, this was a holdover from assembly language, where macros were defined in uppercase along with labels, opcodes, register names and everything else.
Constant Naming ConventionsJava constants should be all UPPERCASE where words are separated by underscore character (“_”). Make sure to use the final modifier with constant variables.
In Python, constants are usually declared and assigned in a module. Here, the module is a new file containing variables, functions, etc which is imported to the main file. Inside the module, constants are written in all capital letters and underscores separating the words.
Its just a style guideline. Programming languages have started to recommend and push formatting conventions so that code is more readable.
Also, symbols that get substituted by the preprocessor deserve special attention-- they live outside/before the type system and may not be what they appear to be. Constants are just constants, they won't change at compile or runtime.
BECAUSE ALL-UPPERCASE IS UGLY AND HARD TO READ AND IT'S INTENDED FOR THE PRECOMPILER, WHICH .NET DOESN'T EVEN HAVE.
Also, Bill Gates wants it that way, and money is never wrong.
Saying that all caps is ugly and thus should not be used is borderline childish logic. It comes from people complaining about what they are not used to.
Having gone from Java to C, I started using underscores_between_words in variable names and functions. camelCase is extremely ugly to me now. But I still use camelCase for C++/Java without complaining because it is convension.
If you can't make yourself flexible, programming will become a harsh mistress. That is the skill of a programmer.
Microsoft doesn't following its own rules because if you reflect over the new System.Threading.Tasks classes in c# 4 YOU_WILL_FIND_LOTS_OF_CAP_CONSTANTS.
Its a style thing. Personally I don't mind. Just be consistent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With