New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

Variable Naming - Hungarian Notations

Free Excel Tips and Tutorials

Variable Naming - Hungarian Notations

Postby Sisyphus » Fri Feb 03, 2012 7:00 am

Some programmers prefer to prefix the names of their variables with an abbreviation of their data type, such as 'strString', intInteger or lngLong. Such prefixes are invariably in lower case and usually consist of 3 characters. The practice goes back to one Charles Simonyi who worked for Xerox PARC in the 1970's and later became a big shot at Microsoft. Mr. Simonyi was of Hungarian extraction and this seems to be the reason for the system being known as 'Hungarian Notations'.
In VBA programming Hungarian Notations don't make much sense because the data types of all variables is openly declared at the top of each procedure. There are other programming languages where this isn't possible. Nevertheless, a guy by the name of Leszynski and his partner Greg Reddick further refined the system. They called the prefixes 'Tags' and added suffixes called 'Qualifiers' to the 'Base Name' and their system became so widely used in Access that they fell out over how to continue its development and each started his own. A list of tags of the Leszynski naming convention is published by Wikipedia:
http://en.wikipedia.org/wiki/Leszynski_naming_convention

Indeed, the attraction of knowing which type of data a variable represents increases with the use of objects. Of these, most Excel programs have few. However, the system need not be applied universally. I apply it where I find it useful and dispense with it where I prefer short names. My For .. Next loops often count i rather than int. My row numbers are represented by R, not lngR, columns by C instead of lngC. But where I need names for, say, an array containing the values in a range of cells and for the range itself I will gladly resort to names like arrHolidays and rngHolidays.
Have a great day! :D

Sisyphus
I do this for "honour and country" - much less of the latter, actually.
If I helped you, award points, plenty of them.
If I bored you, deduct points for being too long-winded. (I know, :lol)
Sisyphus
Former Moderator
 
Posts: 4454
Joined: Dec 7, 2011
Location: Shanghai
Reputation: 203
Excel Version: 2010

Return to Excel Tips and Tutorials

Who is online

Users browsing this forum: No registered users and 30 guests