A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in '2017.2 Beta' started by Deni35, Jul 12, 2017.
Look at this:
I'm sure the Vector3i looks much better.
I don't think it looks better but it does not look worse.
Also, saving two characters while making it more obscure to read isn't something I can get behind, so the verbose version is superior.
I wasn't even aware there was an int version. It must be unique to 2017.2.
Already use a Vector3Int as part of a voxel framework, so this new then.. maybe they should have gone with Vector3i
The .NET Framework Class Naming Guidelines includes the following point:
In this case, it seems Vector3Int is more compliant to the Naming Guidelines than Vector3i, according to the document at least.
If Vector3 were Vector3f (as it is in some other frameworks, such as LWJGL and Ogre), Vector3i would make sense. But as things are, Vector3Int is the better name IMO.
I'm not. ;-)
Verbose is always better IMHO. In today's realm of autocomplete editors, verbose naming is preferred in most cases. It requires no more typing, and is clear and unambiguous.
Don't tell me there's a Vector3Double too.
Vector3Long come back, all is forgiven.
Personally I prefer using the internal Type first, as that maps to how the rest of the syntax of C# works in my head:
IntVector3 foo = new IntVector3(0,0,0);
While I usually agree with the microsoft guidelines, especially regarding abbreviations, one must note that "sparingly" != "never", and you always declare floats with a suffix "f".
float someFloat = 0.5f;
With that in mind, I think it makes perfect sense to suffix a class/struct with "f" or "i" if it deals primarily with floats or integers, etc. However, with that logic, one would think Unity's Vector3 struct deals primarily with doubles(or ints) since it's NOT suffixed.
It doesn't really matter how you twist and turn this, there will be inconsistencies so it doesn't really matter.
I think this is something that will be adapted so quickly and easily that no one will really care in the long run.
I would very strongly prefer that Int/I/i be placed either before "3" or before "Vector." I'm making a library to mirror Unity's vector types in C and for conversions I need to have the input and output types to be separated in some way (each function must have a unique name in C). For example, a function converting a float vector to an int vector might have the signature:
VectorI3 MkVectorI3F(Vector3 vector)
If the vector's component type is used as a suffix this becomes
Vector3i MkVector3if(Vector3 vector)
Which blows because the separation between the input/output types is less clear, and also, it looks like "if."
Some other opinions:
Using "Int" I think is kind of dumb. If any code uses Vector3Int it will use it a lot and you'll spend a lot more time typing it than figuring out what it means.
A trailing "i" isn't great because it looks quite a bit like a semicolon.