Variable Names
-
After 10 years of experience I've a tendency to fully spell out variable names in my code and in field names in my databases. I used to shorten things but I found over time that abbreviated names have a tendency to be very inconsistent from class to class or database to database. I'm getting too old to remember clever naming conventions. For example, in a production database that I'm currently slogging through (designed by someone else) the word OBJECT in some field names is OBJECT, while in others it's OBJ much like this: FIN_OBJ_CODE, OBJECT_CD_NM. As you can see, CODE also changes from CODE to CD depending upon the field. For a field that holds 'object code name' you could have: OBJ_CD_NM OBJECT_CD_NM OBJECT_CODE_NM OBJECT_CODE_NAME OBJ_CODE_NM OBJ_CODE_NAME OBJ_CD_NAME WTF_I_FORGOT_TEH_NAME By the time you spread that nonsense through parameters, objects, object properties, fields and so forth one might end up with a dozen or more names for the exact same field. objCodeName _OBJECT_CODE_NAME ObjectCodeName _strObjectCodeName @INeedANewJob NameObjectCode It may get a wee bit tedious that times but now I just spell out the entire name of the field whether I'm naming a table, field, property, parameter or whatever. In the long run I find it less confusing. In the example above, everything is ObjectCodeName. Does anyone else do this or is it just us early onset Alzhemier's victims?
-
After 10 years of experience I've a tendency to fully spell out variable names in my code and in field names in my databases. I used to shorten things but I found over time that abbreviated names have a tendency to be very inconsistent from class to class or database to database. I'm getting too old to remember clever naming conventions. For example, in a production database that I'm currently slogging through (designed by someone else) the word OBJECT in some field names is OBJECT, while in others it's OBJ much like this: FIN_OBJ_CODE, OBJECT_CD_NM. As you can see, CODE also changes from CODE to CD depending upon the field. For a field that holds 'object code name' you could have: OBJ_CD_NM OBJECT_CD_NM OBJECT_CODE_NM OBJECT_CODE_NAME OBJ_CODE_NM OBJ_CODE_NAME OBJ_CD_NAME WTF_I_FORGOT_TEH_NAME By the time you spread that nonsense through parameters, objects, object properties, fields and so forth one might end up with a dozen or more names for the exact same field. objCodeName _OBJECT_CODE_NAME ObjectCodeName _strObjectCodeName @INeedANewJob NameObjectCode It may get a wee bit tedious that times but now I just spell out the entire name of the field whether I'm naming a table, field, property, parameter or whatever. In the long run I find it less confusing. In the example above, everything is ObjectCodeName. Does anyone else do this or is it just us early onset Alzhemier's victims?
I do it for a majority of things. The exception are objects that I ALWAYS abreviate the same way. tbl for table, cb for check box, cbo for combo box, vw for view and some others. These abreviations are not used for anything else and are always used when that type of object occurs. Otherwise, the more robust the variable name the better for reading the code. The easier it is to read, the less comments I have to make. The other exception is when I have to loop through something where the name of the iterator doesn't matter, then it is 'j'.
-
I do it for a majority of things. The exception are objects that I ALWAYS abreviate the same way. tbl for table, cb for check box, cbo for combo box, vw for view and some others. These abreviations are not used for anything else and are always used when that type of object occurs. Otherwise, the more robust the variable name the better for reading the code. The easier it is to read, the less comments I have to make. The other exception is when I have to loop through something where the name of the iterator doesn't matter, then it is 'j'.
RJOberg wrote:
The other exception is when I have to loop through something where the name of the iterator doesn't matter, then it is 'j'.
Blasphemer! i is the one true loop variable. ;P
-
RJOberg wrote:
The other exception is when I have to loop through something where the name of the iterator doesn't matter, then it is 'j'.
Blasphemer! i is the one true loop variable. ;P
-
After 10 years of experience I've a tendency to fully spell out variable names in my code and in field names in my databases. I used to shorten things but I found over time that abbreviated names have a tendency to be very inconsistent from class to class or database to database. I'm getting too old to remember clever naming conventions. For example, in a production database that I'm currently slogging through (designed by someone else) the word OBJECT in some field names is OBJECT, while in others it's OBJ much like this: FIN_OBJ_CODE, OBJECT_CD_NM. As you can see, CODE also changes from CODE to CD depending upon the field. For a field that holds 'object code name' you could have: OBJ_CD_NM OBJECT_CD_NM OBJECT_CODE_NM OBJECT_CODE_NAME OBJ_CODE_NM OBJ_CODE_NAME OBJ_CD_NAME WTF_I_FORGOT_TEH_NAME By the time you spread that nonsense through parameters, objects, object properties, fields and so forth one might end up with a dozen or more names for the exact same field. objCodeName _OBJECT_CODE_NAME ObjectCodeName _strObjectCodeName @INeedANewJob NameObjectCode It may get a wee bit tedious that times but now I just spell out the entire name of the field whether I'm naming a table, field, property, parameter or whatever. In the long run I find it less confusing. In the example above, everything is ObjectCodeName. Does anyone else do this or is it just us early onset Alzhemier's victims?
Always use the full name except for initials where there is an agreement that they make sense. In trading, there is a deal called a Contract For Difference. The field name [here] to mark an order as a CFD is
isCfd
. If you're working in .net, try mandating FX Cop, which will then warn of variable names not in the dictionary.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
-
After 10 years of experience I've a tendency to fully spell out variable names in my code and in field names in my databases. I used to shorten things but I found over time that abbreviated names have a tendency to be very inconsistent from class to class or database to database. I'm getting too old to remember clever naming conventions. For example, in a production database that I'm currently slogging through (designed by someone else) the word OBJECT in some field names is OBJECT, while in others it's OBJ much like this: FIN_OBJ_CODE, OBJECT_CD_NM. As you can see, CODE also changes from CODE to CD depending upon the field. For a field that holds 'object code name' you could have: OBJ_CD_NM OBJECT_CD_NM OBJECT_CODE_NM OBJECT_CODE_NAME OBJ_CODE_NM OBJ_CODE_NAME OBJ_CD_NAME WTF_I_FORGOT_TEH_NAME By the time you spread that nonsense through parameters, objects, object properties, fields and so forth one might end up with a dozen or more names for the exact same field. objCodeName _OBJECT_CODE_NAME ObjectCodeName _strObjectCodeName @INeedANewJob NameObjectCode It may get a wee bit tedious that times but now I just spell out the entire name of the field whether I'm naming a table, field, property, parameter or whatever. In the long run I find it less confusing. In the example above, everything is ObjectCodeName. Does anyone else do this or is it just us early onset Alzhemier's victims?
At my previous job - I was slogging through some legacy code in a financial application and came across a variable called Wayne_Gretsky and no one knew what it meant.
If you think that's bleak and cheerless, too bad. Reality doesn't owe us comfort. - Richard Dawkins
-
RJOberg wrote:
The other exception is when I have to loop through something where the name of the iterator doesn't matter, then it is 'j'.
Blasphemer! i is the one true loop variable. ;P
a loop in a loop? ii? :-D
"the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
"No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) -
X is my go to variable name... On the whiteboard. I stab any developer who uses it in typed code, even if its demo code.
"x" and "y" are perfectly valid variables: particularly when you are talking about co-ordinates:
foreach (Control c in Controls)
{
c.Location = new Point(x, y);
x += horizontalSpacing;
y += verticalSpacing;
}Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
After 10 years of experience I've a tendency to fully spell out variable names in my code and in field names in my databases. I used to shorten things but I found over time that abbreviated names have a tendency to be very inconsistent from class to class or database to database. I'm getting too old to remember clever naming conventions. For example, in a production database that I'm currently slogging through (designed by someone else) the word OBJECT in some field names is OBJECT, while in others it's OBJ much like this: FIN_OBJ_CODE, OBJECT_CD_NM. As you can see, CODE also changes from CODE to CD depending upon the field. For a field that holds 'object code name' you could have: OBJ_CD_NM OBJECT_CD_NM OBJECT_CODE_NM OBJECT_CODE_NAME OBJ_CODE_NM OBJ_CODE_NAME OBJ_CD_NAME WTF_I_FORGOT_TEH_NAME By the time you spread that nonsense through parameters, objects, object properties, fields and so forth one might end up with a dozen or more names for the exact same field. objCodeName _OBJECT_CODE_NAME ObjectCodeName _strObjectCodeName @INeedANewJob NameObjectCode It may get a wee bit tedious that times but now I just spell out the entire name of the field whether I'm naming a table, field, property, parameter or whatever. In the long run I find it less confusing. In the example above, everything is ObjectCodeName. Does anyone else do this or is it just us early onset Alzhemier's victims?
"Object" smells of Hungarian notation and elderberries. ;P I'm on a crusade at my workplace to stamp out Hungarian, so I'm just particularly sensitive to those sorts of things. Anyway, Hungarian aside, I use full and complete names. Pascal case or camel case depending on context. The only abbreviation I use is "Id".
-
After 10 years of experience I've a tendency to fully spell out variable names in my code and in field names in my databases. I used to shorten things but I found over time that abbreviated names have a tendency to be very inconsistent from class to class or database to database. I'm getting too old to remember clever naming conventions. For example, in a production database that I'm currently slogging through (designed by someone else) the word OBJECT in some field names is OBJECT, while in others it's OBJ much like this: FIN_OBJ_CODE, OBJECT_CD_NM. As you can see, CODE also changes from CODE to CD depending upon the field. For a field that holds 'object code name' you could have: OBJ_CD_NM OBJECT_CD_NM OBJECT_CODE_NM OBJECT_CODE_NAME OBJ_CODE_NM OBJ_CODE_NAME OBJ_CD_NAME WTF_I_FORGOT_TEH_NAME By the time you spread that nonsense through parameters, objects, object properties, fields and so forth one might end up with a dozen or more names for the exact same field. objCodeName _OBJECT_CODE_NAME ObjectCodeName _strObjectCodeName @INeedANewJob NameObjectCode It may get a wee bit tedious that times but now I just spell out the entire name of the field whether I'm naming a table, field, property, parameter or whatever. In the long run I find it less confusing. In the example above, everything is ObjectCodeName. Does anyone else do this or is it just us early onset Alzhemier's victims?
I especially like it when other programmers abbreviate words to the point where I have to guess what they mean. Guessing is always good when working in our world. "i, j, k" are fine for generic loop counters. [edited to drop the retarded comment]
"the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
"No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) -
a loop in a loop? ii? :-D
"the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
"No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011)i, then j, then k, then l, then whatTheFrickAmIDoingNestingLoopsThisDeep.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
After 10 years of experience I've a tendency to fully spell out variable names in my code and in field names in my databases. I used to shorten things but I found over time that abbreviated names have a tendency to be very inconsistent from class to class or database to database. I'm getting too old to remember clever naming conventions. For example, in a production database that I'm currently slogging through (designed by someone else) the word OBJECT in some field names is OBJECT, while in others it's OBJ much like this: FIN_OBJ_CODE, OBJECT_CD_NM. As you can see, CODE also changes from CODE to CD depending upon the field. For a field that holds 'object code name' you could have: OBJ_CD_NM OBJECT_CD_NM OBJECT_CODE_NM OBJECT_CODE_NAME OBJ_CODE_NM OBJ_CODE_NAME OBJ_CD_NAME WTF_I_FORGOT_TEH_NAME By the time you spread that nonsense through parameters, objects, object properties, fields and so forth one might end up with a dozen or more names for the exact same field. objCodeName _OBJECT_CODE_NAME ObjectCodeName _strObjectCodeName @INeedANewJob NameObjectCode It may get a wee bit tedious that times but now I just spell out the entire name of the field whether I'm naming a table, field, property, parameter or whatever. In the long run I find it less confusing. In the example above, everything is ObjectCodeName. Does anyone else do this or is it just us early onset Alzhemier's victims?
It doesn't matter if I abbreviate OBJ or verbose OBJECT_OF _SOME KIND_OR_ANOTHER_BUGGERIT_BUGGERIT_BUGGERIT as long as I am consistent in my naming. I have been so for the last 5 years...
Alberto Bar-Noy --------------- “The city’s central computer told you? R2D2, you know better than to trust a strange computer!” (C3PO)
-
After 10 years of experience I've a tendency to fully spell out variable names in my code and in field names in my databases. I used to shorten things but I found over time that abbreviated names have a tendency to be very inconsistent from class to class or database to database. I'm getting too old to remember clever naming conventions. For example, in a production database that I'm currently slogging through (designed by someone else) the word OBJECT in some field names is OBJECT, while in others it's OBJ much like this: FIN_OBJ_CODE, OBJECT_CD_NM. As you can see, CODE also changes from CODE to CD depending upon the field. For a field that holds 'object code name' you could have: OBJ_CD_NM OBJECT_CD_NM OBJECT_CODE_NM OBJECT_CODE_NAME OBJ_CODE_NM OBJ_CODE_NAME OBJ_CD_NAME WTF_I_FORGOT_TEH_NAME By the time you spread that nonsense through parameters, objects, object properties, fields and so forth one might end up with a dozen or more names for the exact same field. objCodeName _OBJECT_CODE_NAME ObjectCodeName _strObjectCodeName @INeedANewJob NameObjectCode It may get a wee bit tedious that times but now I just spell out the entire name of the field whether I'm naming a table, field, property, parameter or whatever. In the long run I find it less confusing. In the example above, everything is ObjectCodeName. Does anyone else do this or is it just us early onset Alzhemier's victims?
MehGerbil wrote:
Does anyone else do this...
I do. I've never been a fan of shortened names (e.g., no vowels, abbreviated abbreviations), especially when there's no reason.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
"x" and "y" are perfectly valid variables: particularly when you are talking about co-ordinates:
foreach (Control c in Controls)
{
c.Location = new Point(x, y);
x += horizontalSpacing;
y += verticalSpacing;
}Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
After 10 years of experience I've a tendency to fully spell out variable names in my code and in field names in my databases. I used to shorten things but I found over time that abbreviated names have a tendency to be very inconsistent from class to class or database to database. I'm getting too old to remember clever naming conventions. For example, in a production database that I'm currently slogging through (designed by someone else) the word OBJECT in some field names is OBJECT, while in others it's OBJ much like this: FIN_OBJ_CODE, OBJECT_CD_NM. As you can see, CODE also changes from CODE to CD depending upon the field. For a field that holds 'object code name' you could have: OBJ_CD_NM OBJECT_CD_NM OBJECT_CODE_NM OBJECT_CODE_NAME OBJ_CODE_NM OBJ_CODE_NAME OBJ_CD_NAME WTF_I_FORGOT_TEH_NAME By the time you spread that nonsense through parameters, objects, object properties, fields and so forth one might end up with a dozen or more names for the exact same field. objCodeName _OBJECT_CODE_NAME ObjectCodeName _strObjectCodeName @INeedANewJob NameObjectCode It may get a wee bit tedious that times but now I just spell out the entire name of the field whether I'm naming a table, field, property, parameter or whatever. In the long run I find it less confusing. In the example above, everything is ObjectCodeName. Does anyone else do this or is it just us early onset Alzhemier's victims?
I try to stick with a shortened, but meaningful name. But with advancing age I find it useful to document my work separately by listing the name, type, and use for each variable as I create it. Of course, it's not age, really, that drives me to this extreme measure, but the fact that I never have the time to sit down a build an app in one go. It often can be weeks or months between sessions at the IDE, by which time I've completely forgotten what I was trying to do. A quick review of my notes helps a lot to get me back into the project. Happily, I don't have to do this for a living, so I can plod along in any way that suits me with no boss breathing down my neck and shouting about deadlines; I set my own, and ignore them at will. :-D
Will Rogers never met me.
-
i, then j, then k, then l, then whatTheFrickAmIDoingNestingLoopsThisDeep.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
OriginalGriff wrote:
whatTheFrickAmIDoingNestingLoopsThisDeep
exactly. :)
"the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
"No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) -
At my previous job - I was slogging through some legacy code in a financial application and came across a variable called Wayne_Gretsky and no one knew what it meant.
If you think that's bleak and cheerless, too bad. Reality doesn't owe us comfort. - Richard Dawkins
dexterama wrote:
Wayne_Gretsky
Probably a variable that could stick handle. See Wayne Gretzky[^]. :)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
-
a loop in a loop? ii? :-D
"the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
"No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011)for ( int i=0; i<10; i++)
{
for ( int eye=0; eye<10; eye++)
{
for (int aye=0; aye<10; aye++ )
{
}
}
} -
for ( int i=0; i<10; i++)
{
for ( int eye=0; eye<10; eye++)
{
for (int aye=0; aye<10; aye++ )
{
}
}
}:laugh:
"the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
"No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011)