RSS

Example of Why You Shouldn’t Use Hungarian Notation

16 Mar

So today had to go into a project and make a small change from a regular textbox to a Masked Numeric TextBox the control was for Phone Numbers to be used for a contacts object that is gotten and updated throughout the session and used in multiple other places in the web site. problem was is that the hungarian annotation had to be changed through out. Anywhere the object or session object was referenced. Also it was being placed into a local object in other places, so find and replace did not work for all those who were about to shout it. example:

TextBox alter_tbxPhoneNumber = (TextBox)Session["tbxPhoneNumber"];

This broke because the object was no longer a TextBox and therefore you can’t cast it to a TextBox nor can you place it into a TextBox object. If you’re a developer and you can’t mouse over a variable name to see what type it is or simply use getType then object orientation isn’t for you in the first place. Just my opinion though. Till next time don’t let your code have a meltdown.

Advertisements
 
2 Comments

Posted by on March 16, 2012 in Uncategorized

 

2 responses to “Example of Why You Shouldn’t Use Hungarian Notation

  1. John

    March 17, 2012 at 12:15 am

    Why would a textbox be in the session?

     
    • atomiccode

      March 21, 2012 at 5:52 pm

      I didn’t design the original code I just corrected it and it is in the session because they created a wizard of sorts and stored all the inputs there and then at the end submitted it all to a proc. Horrible procedure I know. Also if your going to post here do not use johndoe.com anymore or I won’t allow your posts.

       

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: