by Paulo Morgado via Paulo Morgado : C# on 5/20/2007 10:28:43 PM
I'm a firm supporter of coding conventions (at least of my coding conventions).
Software factories [^] [^] [^] and other code generation tools have been taking care of writing the tedious (and, sometimes, ugly) code but, at some point, some code must be written and read by human developers. That's why (in my opinion) the way the code is written is as much important as the language it is written in.
There are several resources about coding conventions for the .NET framework:
I haven't read Brad and Krzysztof's book (yet), but I've read MSDN Library's guidelines and Juval's document and watched Krzysztof's presentation.
I have to disagree with Microsoft's position about naming conventions of private members. In an enterprise as big as Microsoft projects start and end, people move between teams and every time someone changes team he/she is faced with the possibility of having to learn and adapt to a new set of naming conventions for private members.
IDesign goes one step further on defining naming conventions for private members. I just don't like the convention they used. What's the point of prefixing private member fields (not variables as in their document) with m_? What does it mean? Member? If it's not a local method variable or a method parameter it's a member.
Some just prefix with _. Once again, why? What does that mean?
The only reason I can find for this prefixing practice is lost in the old days of colorless IDEs, printers and books. With colorful IDEs like Visual Studio 2005 you just need to qualify instance member fields with the this (Me for Visual Basic) keyword and static (Shared in Visual Basic) member fields with (lacking of a better solution) the class name.
Lets pretend for a moment that I'm one of the prefixes. How would I do it?
Why stop there? Let's also prefix method variables:
Now I'm on a roll. Let's prefix method parameters:
The next step would be to go Hungarian and add type information to the names, right? No. Let's stop here and get in the right track.
I Find that keeping naming conventions as simple as possible is the best way use and validate them.
Original Post: Naming Conventions for C#
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.