Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

txtFirstName vs FirstNameTxt

Over the past several years I have been using the naming convention of FirstNameTxt when I'm referring to a TextBox Control for a 'First Name' field. However, I've noticed the majority of other developers tend to use the naming convention txtFirstName

Which is the best convention to use? and why is it preferred over the other method?

like image 207
Curtis Avatar asked Jun 28 '10 13:06

Curtis


2 Answers

I like using the Hungarian Notation - prepending with a 3-letter abbrev - if for any other reason, all the textbox controls are grouped together in the list of controls for the page.

like image 124
DShultz Avatar answered Nov 18 '22 00:11

DShultz


Since Visual Studio 2010, there is absolutely no reason to use Hungarian Notation.

The only reason one could imagine - to easily search for similar controls with intellisense, goes away with new intellisense which searches in full text.

Thus typing Text in code editor finds you all: firstNameText, lastNameText, anyText.

And it's much easier to read "firstNameText" than "txtFirstName" in code.

like image 1
František Žiačik Avatar answered Nov 18 '22 01:11

František Žiačik