» Home
» Tutorials
» Search  
» Contact us 

Home » Tutorials » Introduction to Visual Basic .NET » Chapter 2

2.3: Creating a Simple Application

2.3.5: Modified Hungarian Notation

Modified Hungarian Notation

You may have noticed that the names given to the controls look a little funny. Each name is prefixed with a shorthand identifier describing the type of control it is. This makes it much easier to understand what type of control you are working with when you are looking through the code. For example, say you had a control called simply Name, without a prefix of lbl or txt. You would not know whether you were working with a text box that accepted a name or with a label that displayed a name. Imagine if, in the previous exercise , you had named your label Name1 and your text box Name2 you would very quickly become confused. What if you left your application for a month or two and then came back to it to make some changes?

When working with other developers, it is very important to keep the coding style consistent. One of the most commonly used styles for control names within application development in many languages was brought forth by Dr. Charles Simonyi, who worked for the Xerox Palo Alto Research Center (XPARC) before joining Microsoft. He came up with short prefix mnemonics that allowed programmers to easily identify the type of information a variable might contain. Since Simonyi is from Hungary, and the prefixes make the names look a little foreign, the name “Hungarian Notation” came into use for this system. Because the original notation was used in C/C++ development, the notation for Visual Basic .NET is termed Modified. The following table shows some of the commonly used prefixes that you shall be using in this tutorial.

Hungarian Notation can be a real time-saver when you are looking at code someone else wrote or at code that you wrote months earlier. However, by far the most important thing is to be consistent in your naming. When you start coding, pick a convention for your naming. It is recommended that you use the de facto standard Modified-Hungarian for Visual Basic .NET, but it is not required. Once you pick a convention, stick to it. When modifying others’ code, use theirs. A standard naming convention followed throughout a project will save countless hours when the application is maintained. Now let’s get back to the application. It’s now time to write some actual code.

 

click next Page - The Code Editor.

Home | Link to Us | Partner Links | About us | Contact us

Copyright © 2009-2012 F1tutorials.com | All Rights Reserved