OCDProgrammer.com

It's Microsoft's World, and I'm just living in it
View Clarence Klopfstein's profile on LinkedIn

Clarence Klopfstein's Facebook profile

This site is under construction...

Categories

New Comments

Referring Sites


Disclaimer

  • This is MY blog. The views represented here are not in relation to anybody else. Please read my full disclaimer for a more complete disclaimer.

Naming Conventions

January 18, 2008 21:11 by ckincincy

Well if you've been a programmer for any length of time, this better be something you're familiar with.  If it's not... change and follow these rules for the sake of humanity.

I've had the joy over the past few months to work on two projects I inherited from others... the coding standards are killing me.

So lets work this out, lets say you have a text box for a name.  The proper naming convention of that text box is NOT:

NameTxt. 

The proper naming convention of this text box IS:

txtName

You see that.. the type of object goes in FRONT of the variable name. 

There is this neat little trick we have available to us in modern IDE's.  When I know I am looking to edit a Button I start by typing btn... and you know what happens?  I get a pop up with all the buttons on my form.

I really thought this was programming 101... guess not.

So here are a few of my naming conventions, frankly I don't care if you follow this.. just be consistent so the person that follows you can figure it out!

Button: btn
Radio Button: rdo
Label: lbl
Text Box: txt
Drop Down List: ddl

Really is this that hard?


Categories: Programming
Actions: E-mail | Permalink | Comments (1) | Comment RSS

Comments

November 12. 2009 12:21

You are correct, it makes no sense to follow a naming convention at the end of the object name such as firstNameTxt.  One of the reasons for following a naming convention on similar object types is for ease of type recognition.  Since we read in english from left to right, it only makes since to start the naming convention on the left such as txtFirstName. This way as soon as you read the object name (starting from the left as english is read), you can identify its type.

Bob

bob |

Comments are closed