Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Form Elemnet Naming Conventions (C#)

Are there any (Microsoft-sanctioned or otherwise generally accepted) naming conventions for variables that point to form elements?

Do you guys put Hungarian-type notation like ddlFooBar and lblBaz or even full names like DropDownListFooBar or FooBarDropDownList.

Or perhaps you just call the element FooBar and let the code/IDE tell you that its a form element?

I'm working on an app that is terribly inconsistent and I'm not sure which way to go.



Thomas David Baker
Wednesday, November 26, 2003

Camel-case is recommended and preferred. Eg:


This applies to any managed code (components, services, classes, web forms etc).

Wednesday, November 26, 2003

There's nothing official AFAIK - just be reasonably consistent with whatever you choose :-). Regarding the naming-convention, we go for easier to pronounce suffixes like:

I just find "age range list" etc eaier to say and think about that the awkward "list age range".

The underscore is because of the naming convention we use for class/module-level variables (which is all controls effectively are) to distinguish them from local variables.

Duncan Smart
Thursday, November 27, 2003

I tend to name my controls:


Lowercase initial letter because they're private variables of my form class, and I put the full suffix on there because it makes it easier to tell what's what. I don't like doing lblAge, for example, I find that much harder to read.

Chris Tavares
Wednesday, December 03, 2003

*  Recent Topics

*  Fog Creek Home