views:

241

answers:

7

In my project currently we are using All caps as naming convention for constants. I would like to change it and I'm OK with Pascal Casing but my team lead has a strong argument that it will not visibly distinguish constant from Properties and other Types.

Please help me with any other suggestions.

RESULT As @Paolo Tedesco and most of the people here thinks, I will stick to ALL_CAPS. Anyways I don't have other option also now as the argument provided by @24x7Programmer couldn't change my team lead's mind. Now further I can't argue on this little issue.

Thank you every one for your suggestions.

+1  A: 

I personally think that ALL_CAPS_CONSTANTS_LOOK_UGLY, but your team leader has a good point in saying that they are easily distinguishable from everything else.
What is your point for changing the convention? If it's only an aestethical preference, then I think that you should adapt to the convention in place - as a professional developer you must be able to read and write code also if it does not conform to your preferences...

Paolo Tedesco
I personally think that ALL_CAPS_CONSTANTS_ARE_BEAUTIFUL
Ion Todirel
I agree and I always use them.
SLC
+1 As you said I will stick to it even if it doesn't fits my taste.
Ismail
@Ion Todirel: oh, well, DE_GUSTIBUS_NON_EST_DISPUTANDUM.
Paolo Tedesco
A: 

This is a subjective question. There isn't an iron-clad proof that all-caps is a bad idea, so just go with the flow. This kind of issue isn't worth going to war over.

Marcelo Cantos
I've given my problem. It is a genuine one and I'm asking for suggestions. Why do you think it is subjective? Every one will give their suggestion. I will accept it as suggestions. Good if it helps otherwise also is good.
Ismail
It is subjective because there is no fundamental law of the universe that favours camel-case over all-caps. Why do you think it isn't subjective?
Marcelo Cantos
A: 

Why do you have to be able to distinguish constants easily? In C++ and C it made sense that you wanted to be able to distinguish macros easily, but I can't think of any good reason for that being needed. I used to use all upper case out of habit, but mostly changed to Pascal casing now since it fits better with the rest of the code.

Edit: Though I agree with the other answers that it's very subjective anyway, so if you've already got a standard, I can't say that it would be worth changing it.

ho1
+3  A: 

In our projects we usally define a separate class for constants and use only Pascal naming for them. So we refere constants something like this:

Functionality1Constants.ThisIsAContant
24x7Programmer
I liked your idea. We also have a constant class but I'd not thought that I could have put it as my argument.But my team lead is still not agreeing with it. +1 though.
Ismail
+2  A: 

There are official Naming Guidelines for .NET, to which most .NET developers adhere. For me, you'd need a much better reason than "it will not visibly distinguish constant from Properties and other Types" to deviate from these guidelines.

If you follow them, your code will look like .NET code, rather than like C++ code that is being compiled with the C# compiler.

OregonGhost
You are right. But my team lead doesn't think like that.
Ismail
+4  A: 

MSDN sets out naming guidelines for C# quite clearly. If someone new were to come and join your team, would you really want to waste time explaining to them your conventions? If they were to dive straight into the code without knowing your conventions, would you really want them to waste time in confusion trying to muddle out what's what and spending most of their time coding used to your conventions? People need to accept that each language has it's own set of conventions and realise that the best practice is to stick to them. It'll save you, your team members and new members a lot of time and headache.

Sorry to sound so melodramatic, but I find it hard enough naming classes and members. The less time I spend thinking about upper-casing, camel-casing and pascal-casing the better.

alimbada
+1 I don't want to waste time on this. Thanks.
Ismail
+1, great answer.
OregonGhost
A: 

First decide what's important for constant names, and let that lead the convention. Consider:

  • That it's a constant
  • Readability
  • Meaning of the name
  • It's data type

I feel that the readability and meaning is most important. The data type can sometimes be important, but then it should be evident from the name anyway. So, I would skip trying to make constants stand out just because they are constants, and use the same convention as for naming variables or properties.

Guffa