Ken, I was wondering what personal variable naming convention you adhered to while programming. To me, it appears to be an efficient convention.
Thanks
Awesoken at
Re: Ken: variable naming conventions...
I make local variable names as short as possible: i, j, k, etc.. for integers; f, g, .. for floating point; x, y, z for coordinates. I use longer variable names for global variables, and all caps for constants.
yuriks at
And don't forget daVars...
Awesoken at
I don't do that anymore. To explain Yurik's comment: I used to precede local variable names with 'da' to distinguish them from global variables which might share the same name. It was inspired from a skit on Saturday Night Live (an American comedy show).
TX at
Damn, you don't do that anymore? At least kplib still has quite a few instances of it. :D
fruitbag at
Ken -- what about QBasic naming conventions? I've noticed that you use conventions like z% and zz%, and common uses of 'k' to denote variables.
Awesoken at
Parts of KPLIB.C were written in 1998, although things like "daframeplace" were probably written when I put it all together in 2001. When I add a new function, I try to save time by copying & pasting from elsewhere in the code if there's something similar. This is why those function parameters have remained.
The percent signs in QB specify that it is an integer. Sometimes, I'll avoid that by putting a DEFINT A-Z at the top, but not always. In the old days, I might have used z and zz for loop counters, whereas today I prefer i and j, or x and y.
I'm not sure what you expect to learn by studying my naming conventions. I do things because they make sense at the time. I suggest you do what makes the code easiest for you to read. Use funny names if they make you laugh. Use shorter names if you're slow at typing. Unless you're working on a team project, naming conventions don't really matter.
Zardalu at
Use naming conventions that make sense to YOU. I have trouble sometimes reading Ken's code, but that's just because he uses his own naming conventions. If anyone's interested, my conventions are something like this:
I use capitalisation only for global variables. ALL caps for constants, and caps only for words for global variables (like "ThisIsAGlobalVariable"). I hate to use underscores, but I will use them whenever I use classes (m_ThisIsAClassVariable). For simple loops I use variables like i,j,k,m, ... (I usually avoid "l" because it's too close to "1".).
My advice is: Don't copy someone else's usage. Use something that makes sense to YOU. That is the best way to understand your own code when you go back to it later. Don't bother with what the open source community does. Don't bother with things like "dwVariable". Use what makes the most sense to YOU. Nothing is more annoying than understanding someone else's code. That's not coding. If you are a professor at a university, yes, then, maybe, you should make things clear. Because you are TEACHING. But when writing your own code, use things that YOU understand. Really, DO NOT care about other people understanding it. That only makes it harder for you.
Just my opinion. And I think it fits in with Ken's reply. Why do you care about Ken's naming conventions? Use a style that YOU are comfortable with.
Ben Jos.
Zardalu at
Just as an example: Download the Rubix source code from Ken's site. It contains code written by Ken and code written by me. And when you look at the source code, you will see that we have VERY different "conventions". Yet, it took only 2 emails for Ken and me to create an interface...