I'm just wondering how everyone names their arrays. Do you use plural or singular? I personally find that whatever style you choose, there's times where reading the code does not make sense. So, what's your preference?
Vector3 vertex[10];
Vector3 vertices[10];
vertex[0].translate(); //this makes sense when I read it
vertices[0].translate(); //this doesen't read as nicely
//now say you have a function that takes an array as a parameter
translateArrayOfTenVertices(vertex); // does not read nice at all
translateArrayOfTenVertices(vertices); //this sounds nice
Personally i would not call an array for Vector3 vertex or vertices(perhaps only for testing, but i use test/temp for that).
I'd pick an identifier that describes their task or what they represent, rather than their kind, if the identifier name was not obviously indicating it was of type Vector3, like "shoe" instead of "polygon", to maintain legibility in the sense of being able to tell what kind of object it was, i would use some form of hungarian notation..
Vector3 polygon[10];
Vector3 v3_Face[10];
polygon[0].translate();
v3_Face[0].translate();
//now say you have a function that takes an array as a parameter
translateArrayOfTenVertices(polygon);
translateArrayOfTenVertices(v3_Face);
// I'd probably name this something else and not bound it to 10, make it dynamic.
// also you need to supply it a translation vector, no?
v3_Translate(polygon, Vector3 t_Vec);
v3_Translate(v3_Face, Vector3 t_Vec);
but again, this is all what you like and what works for you. If you ever end up in a programming job where you have to collaborate with other programmers you will probably get a coding standard document, saying this is how you name what and comment how and stuffs like that.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
// I'd probably name this something else and not bound it to 10, make it dynamic.
// also you need to supply it a translation vector, no?
Yes, it isn't a real function. I simply made it up to demonstrate the array's name.
Anyway, you made a good point about naming the array "polygon". While this makes sense in this particular case, what about a more general case. Say you have an array of 2 Circle objects, they are independent of eachother and they exist without being part of something bigger. How would you name the array?
Circle circle[2];
Circle circles[2];
I realize this discussion is pretty much unneccessary but I'm interested in knowing everyone's preference because I would like to follow along with the majority.
Bare in mind, the answer i give to your question is merely my opinion on how i "like" doing things, by no mean is it the "right" way, not that there is one on naming conventions.
I'd have to look at what the 2 circles did or represented. For instance, if they represented 2 independent collision circles for a 2 player game, I'd name them something like,
Circle playerCollision[2];
However, if it was a object that needed to maintain scope, and something that was not concrete in size id dynamically allocate it and name it a little differently.
Lets use Circle as the data type again, and lets say it represented a bunch of particles. I'd probable do something like
Circle *particleList = (Circle*)malloc(sizeof(Circle)*how_many);
or maybe
Circle *p_Particles = (Circle*)malloc(sizeof(Circle)*how_many); // i sometimes use p_ to donate that its a pointer;
Anyways, like i said, its just my preference, and in no way is "right" but could be argued to be better than naming things a, b, var, or any arbitrary term like that.
Just find something that works for you. You'll notice that a variable is not named wel,l when you look at code 3 months after writing it, and going what does CircleList do?
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"