Favourite name for vectors?

Hey guys, its a personal question, close to the heart of all game programmers. How do you name vectors?

We got a list to choose from : vec3,vect3,Vec3,Vect3,Vector3,Vector3f,float3,and many more.

What do you like?

I’m going to call all mine “Jennifer”.

I like that the vectors (indeed any field) are named after their purpose (No! I am not going to discuss the purpose of “Jennifer”).
None of my fields are ever called vec3 or likewise.
cameraPosition is so much more understandable than vec3.

I like names that make up sentences that BA might have said, so I call them things like “jibba”, “jabba”, “crazy” and “foo”. It makes for very readable code too. If you’re howlin’ mad.

Breakfast - that was very painful.

I’m using some crazy form of weak Hungarian (I think it is) or something like that, so I’d choose something like v3fIdentifier, where Identifier is what this thing’s purpose is. I also abstain on what v3fJennifer might be for. evil grin

Please! No Hungarian notation! Hungarian notation only makes code less readable instead of more! If you can’t identify your variable types, you need to clean up your code so you can see your definitions. After all, Hungarian notation was developed at MICROSOFT of all places. That should be a good tipoff that it’s not a solution for clean code.

I agree with the MS comment, though I disagree on the readability. I HAVE been using this scheme for almost four years now, and it’s just what is comfortable for me. As was mentioned earlier, it is an opinion.

Hungarian notation was developed by MS? Why is it called Hungarian notation? Why not Microsoftian Notation? Were the people of hungary even consulted?

The gentleman who created it was Hungarian, I believe…

… goes along with how you get things like Reverse Polish Notation (which I think is absolutely brilliant, btw).

Love RPN. You can do math, left to right without ever worrying about “decoding” operator priority. My biggest beef with Hungarian notation is that it smacks of a hack on top of a hack. Since the guys at Microsoft could no longer find what their variable definitions were, they created a syntactical standard that put the definitions in the name. Unfortunately, the world got trained to use it, and now we have the joys of code like “hwndMyWindow” even in Java where it’s pretty much unnecessary. But you’re right, a lot of people use it and are used to it. Which is too bad for them, because I’m always on a crusade to get people to produce nothing but the cleanest code. :wink:

Don’t have a favorite name for vectors, but I usually call my buffers “buffy”.

Okay, I was kidding, but I have the horrible feeling you’re being serious… ;D

With me, a temporary values are easy - a ByteBuffer will usually be called “bb”, a Sprite will probably be “s”, “i” is used for iterating over arrays (move on to “j” and “k” if nesting), and “x” and “y” are for iterating over two-dimensional arrays that have some concept of coordinates etc etc. Longer-lived references are similarly standardised, but are descriptive based on use/contents rather than type.

I suppose it really doesn’t matter what scheme you use as long as you’re consistent. I’ve developed my system so that I can look over code I’d written many moons before and understand what it all means with very little effort. This is helped by good API design and liberal documentation.

I think the original question was specifically about the naming of vector types. They’re described in so many different ways that I’m sure all of the mentioned forms are present in an API somewhere. I would stay with Capitalisations for class names, and would try to avoid suffixing with “3” - it’s not hard to write a class that will represent all the dimensions you throw at it, and remember what it’s supposed to be. As for the length of the name (vec/vect/vector), I think that’s entirely personal choice. For me, I’d go with “Vector” because I don’t like things unnecessarily abbreviated. Ur mileage may vry.

When Edsger Dijkstra died last year I read a comment somewhere that not only did he contribute a huge amount to computer science but he was also the only high profile computer scientist to have the classic loop variables i, j and k in order in his name.

[quote]horrible feeling you’re being serious…
[/quote]
well, half serious, half tounge firmly in place. :smiley:

Hey cfmdobbie this is what happends when you ask a question, you find out more than you wanted to know. :slight_smile:

Hungarian notation was created to solve scope problems in C, so theres not much need for it now. Except hordes of people still love it. :slight_smile: Seems to be really popular with C++ coders. Its just what your used to and like i guess.

Im growing fonder of float3. The same naming as the CG language. You won’t find any cleaner! :slight_smile:
I know im breaking the sacred java rules, but i’ll live.

since i’m a XP friend, i always use long informative names. not it’s not hard or time consuming to write since either a) i’m fast or b) i press CTRL+SPACE in Eclipse :slight_smile:

makes code so much easier to read. one thing that annoys me reading other’s code is that people shorten already short variables like Proc for Process! (they do at the university in the OS course, silly)

anyway, i like the JCS since ‘coding conventions’ is one of the xp practices and it’s easy to point people to sun’s site and read it there.

;D

Hey if we are talking coding conventions lets have a fight about the evils of misplaced parenthesis :slight_smile:

I hate Sun’s ‘standard’ way… I like my {} aligned…


if( blah )
{
    woo(hoo);
}

I’ve seen some odd alternatives too… like…


if( blah )
    {
    ew(yuk);
    }

And if I had to name them, I would call them Floyd :D.

[quote] I hate Sun’s ‘standard’ way… I like my {} aligned…
[/quote]
Damn straight, skippy!

Me too! ;D

I like my braces aligned, all apart from in two situations, where I prefer them “split”:

String[] filenames = {
      "foo.txt",
      "baa.rgb",
      "quux.tar.gz"
} ;
f.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e)
      {
            // Code in here
      }
}) ;

I suppose this is because it avoids a hanging equals symbol in the first, and makes the point that it’s an inline class definition in the second. It just seems right in those two situations.

How about asking whether there’s a space before the semi-colon at the end of a statement, spaces immediately padding out parentheses, single-line if/for/do/while constructions with or without braces… ;D

(BTW: yes/no/without)

if((data = in.read()) >= 0) out.write(data);

Extra spaces take up more width without giving back much readability IMHO. Of course, that’s one of those minor points that I’m usually pretty flexible on.

Damn right about the aligned parenthesis. I thought I was the only person who thought the open bracket after the declaration looks stupid.