PDA

View Full Version : [SOLVED:] Can't Find Shortcut Notation Using Prefixes



Cyberdude
05-09-2005, 02:35 PM
I recently saw somewhere a list of shortcut notations that involved using prefixes on the variable names. For example, a variable name that is an array variable might be named aryMyArray. But I can't remember whether those prefixes serve to define the type of variable, or just what the benefit might be. Anyone know what I'm talking about? :bug:

Bob Phillips
05-09-2005, 02:51 PM
Yeah, but it is a style thing. Some people prefix by the variable type (strxxx, ixxx, etc.), some by the purpose.

For instance, I use purpose with
i - an index variable, usually long
c - a count of items, again usually long
f - a flag, usually boolean
o - an object, which can be qualified such as oShxxx for a sheet, oWbxxx for a workbook, oRng... for a range, etc.

but then I lose it when I use s for strings, which is nothing to do with purpos and k for constants (and of course I regulalrly forget anything - rng being my favourite, and cell).

Back awhile, Hungarian notation (the type style) was being propounded as a de-facto standard, but I don't think it quite made it. I adopted it, but lapsed and veered off-road, it is too hard to be so prescriptive.

There is a nice page at http://ootips.org/hungarian-notation.html if you want to read up on it.

Zack Barresse
05-09-2005, 02:55 PM
Believe you are talking about Hungarian type notation. Hungarian type notation has come in many forms and you will hear many different descriptions of it. It's basically where the variable name is preceeded by a number of lowercase letters, usually dependent (by the programmer) on what type of variable it is. It's not needed, but an easy way to quicky identify variables in procedures, and to make them unique and identifiable. It's good practice, especially when compared against using variables like a, x, i, n, etc.

Examples can be found here (http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarw98bk/html/variablenameshungariannotation.asp).

This is a touchy subject with some users/programmers. Good variable declaration is essential as well. This can be quite the argumentative subject. But that's my humble opinion. :)

Bob Phillips
05-09-2005, 03:06 PM
Examples can be found here (http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarw98bk/html/variablenameshungariannotation.asp).

Trust MS to try and set the standard!:whip. Bet they'l claim they invented it next.


This can be quite the argumentative subject. But that's my humble opinion.

No it can't!

Zack Barresse
05-09-2005, 03:10 PM
Trust MS to try and set the standard!:whip. Bet they'l claim they invented it next.
That's not what I got from the link I posted. But I wouldn't put it past some of the older programmers - and their ego's. ;)


No it can't!
My point exactly. :rotlaugh:

Killian
05-09-2005, 03:48 PM
Hiya bud :hi:

I guess the most well-known standard for naming convetions is Hungarian notation, introduced to MS by Charles Simonyi to try and introduce some order to the explosion of code that was around at a time before a lot of the rules and convetions had been written - it's more applicable to languages like C than VB, where thing are a little more straight-forward.

The improvement in readability of your code is significant and the larger the project, the more important it becomes. If you distribute your code or anticipate that some other poor programmer will have to maintain it some time down the road, it's only polite to try and stick to the same kind of conventions that have evolved for VB.

I can tell you from bitter experience that trying to work on code written by someone that just uses the first word that comes to mind in a complete nightmare (and it happens more than you would imagine).

It takes a fair amount of self-discipline to apply consistant conventions to ever line of code you write but it's well worth it if you ever want to read or use those lines of code again!

Cyberdude
05-09-2005, 08:19 PM
Bud?? Does that mean we're getting close? :eek:
OK, if I understand all this, then the notation has no effect on the VBA compiler, i.e., it does not convey any info to the compiler about data type or whatever. The purpose, as I understand it, is to make it easier for the code reader to understand what is happening . . . it would (in concept) make it less necessary for him/her to remember the purpose of each variable as he plogs along.
Thanx all for the enlightenment. :thumb

Zack Barresse
05-10-2005, 08:25 AM
OK, if I understand all this, then the notation has no effect on the VBA compiler, i.e., it does not convey any info to the compiler about data type or whatever. The purpose, as I understand it, is to make it easier for the code reader to understand what is happening . . . it would (in concept) make it less necessary for him/her to remember the purpose of each variable as he plogs along.

Exactly right. :yes