After a feeled million hours of coding in the past 16 years there have been many ways to write code in many different languages. Some seemed correct to the time they were used, some seemed to be too strict or too chaotic and I also evolved my coding style with each new line written. Now considering the results of over 5 years in professionall game development, tools and engine code as hobbyist and on small and large commercial projects up to AAA titles, there are still many ways one could write code in different languages but also in the same language on different projects in one and the same but also different companies. I mostly agree with; see some trends in C#, C++ coding guidelines that are fully worth to go for but the major difference is on the naming conventions.
Because I have currently to write my own coding guidelines (not for a special project but primary as a personal convention to refer to when coding) and seek for a way I'm happy with, I did some research on different guidelines and came up with following references:
When Epic Games write about Unreal
This seems a bit confusing when seeking for some type like Animation or Skin (that are both different prefixed with A and F) but prevents various naming conflicts to types and variables when writing a function that accepts FSkin Skin as parameter for example.
Googles c++ guidelines point into a completely different direction when they write
So they heavily make use of typos, underscores and also lower case prefixes to identify different kinds of member, static, nonstatic and function names and in the same breath except there rules for various special cases.
Some other examples from different projexts I was invovled to also use and do not use prefixing types or use underscores
class Class
{
const <type> cConstant;
const <type> Constant;
const <type> __Constant;
<type> _myClassMember;
<type> _MyClassMember;
<type> myClassmember;
<type> mMyClassMember;
<type> function(<type> parameter);
<type> Function(<type> parameter);
<type> Function(<type> aParameter);
}
class NAClass //avoid using namespaces, instead prefix anything with a 2 letter namespace like identifier
{
...
}
Dont need to mention that Visual Studio will raise a Warning/Exception that a type is named as same as a function parameter when using a class
class Container
{
private int size; //current size
public Resize(int size) //will cause compiler telling that type matches a member type
{
//do resize here
}
}
So in the end anyone does he or she thinks that it is worth to be done and so me do too. I would like to hear your opinions to why and what codings style do you prefer or are involved to in whatever way. What do you think makes a good standard especially for the most common point, Naming Convetions?
Will be corious to read your opinions
↧