As JavaScript is case sensitive, does anyone know if there is a recommended naming convention for variable, function and object (class) names?
When I was new and looking at the examples, I easily got confused about what terms were built into Unity vs. what were variables or script names that could be anything. Maybe all-caps or all-lowercase would help avoid that.
Other than that, I think whatever you find readable is best! The examples/tutorials might show what others have done.
I’ve always seen class names being uppercase and members/variables being lowercase. lowercase class names confuse the hell out of me because I think they’re variables.
Yep, lowercase for variables and uppercase for class names and functions.
–Eric
In OO programming one very common approach is:
=> ThisIsAClass
=> thisIsAFunction( )
=> thisIsAVariable
=> _thisIsAClassVariable
=> IThisIsAnInterface
And exceptions usually have Exception in the end, e.g. IOException, FileNotExistentException.
Can’t recall of anything else right now.
Regards,
Afonso
The convention I work to is:
- Class
- Function()
- propertyOrLocalVariable
- m_MemberVariable (because Unity automatically strips the m_ prefix)
This is consistent with Unity’s API.
Thanks for everyone’s replies.
I think it’s probably best to go with the Unity consistent convention.