What are the naming conventions that you use while coding?
相关问题
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
- Should I use static function in c# where many call
I hope we will not discuss prefixes for field names and brace styles here :)
Here is my bible for .NET:
alt text http://ecx.images-amazon.com/images/I/51HT7RDZW7L._SL500_AA240_.jpg
Also MSDN gives solid guidelines.
Another useful source is MS Internal Coding Guidelines
Pick one at be consistent. Changing name styles leads to confusion.
To add on to the answer from @Aku authors of the Framework Design Guidelines have published on online digest version of their guidelines, with an emphasis on naming convetions.
Framework Design Guidelines Digest v2
Download here
Consistency is key. Depending on the size of your development team, using a consistent and documented convetion will make it easier to pick up someone elses code and for others to pick up your own code.
I use a combination of Hungarian, camel case, and other rules I come up with in the beginning of a project. Like right now:
...etc. Some things are standard, others are up to interpretation, but the most important thing is consistency across your application.
Hungarian notation can be used. I don't bother myself, but I give various things (variables, controls, etc.) sensible names.
For example, I use a Hungarian-style prefix for control names such as txt for TextBoxes, btn for Buttons, pic for PictureBoxes, lbl for Labels, etc. That helps to easily identify what a control is.
For function names I try and use sensible explanatory names, but nothing with any particular rules. For variable names again I just use explanatory names but nothing special.
Here's a list of general naming conventions from MSDN.
I tend to just go-with-the-flow, however. Whatever standards are currently in place, it's usually easiest to just go with them and maybe slowly shift it over time. It's not really practical to just come into a project with your own idea of "standards" and try to implement them.
It doesn't REALLY matter what standards are used, imo -- just that there are some and people know what they are.