views:

451

answers:

7

What are the naming conventions that you use while coding?

+5  A: 

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.

Kevin Fairchild
+9  A: 
aku
Aku is sooooo right! I second his response in a big way.
rp
Here, here, I agree too.
Jon
+2  A: 

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.

robintw
+4  A: 

I use a combination of hungarian, camel case, and other rules I come up with in the beginning of a project. Like right now:

Methods are upper case (DoThis) variables are camel case (thisThing) page level variables are prefaced with _ (_thisWorksEverywhere) regions are all lower case (#region foreign properties) Properties and Objects are uppercase (Object.Property) Foreign properties are prefaced by _ (Object._ForeignGroups) Controls are hugarian to an extent like (txtTextBox) and (rptRepeater) I'm not to strict as to what's customary because "Watermark" can be wm or wk or whatever, as long as they all match each other accross my app.

...etc. somethings are standard, others are up to interpretation, but the most important thing is consistancy accross your app.

Sara Chipps
A: 

Folks, please don't post answers like "I like __field" or "I like m__field". It's a very personal and subjective question without a single answers.

If you have any guidlines it's already a big win. Worse thing in dev team is a lack of common conventions.

It would be nice if would try to describe some benefits of given guideline.
For example:

prefixing fields with underscore can improve auto-completion with intellisense

aku
Subjective question gets subjective answer. News at 11.
rq
RichQ, subjective questions with subjective answers would be closed as fast as I can find them. I tried to make this topic meaningful instead of letting another useless tread to span.
aku
A: 

Pick one at be consistent. Changing name styles leads to confusion.

Jim C
+1  A: 

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.

Jon
Jon, thank you for useful info!
aku