I want rise topic about coding style that we use. Now because of many
people working we have a lot of different styles of writing code.
I totally agree.
The only bad thing I see here are using "unsigned int" and "uint8_t" in same part of code.
My view here is simple:
- when one wants to use a variable with a very specific bit size, as
when reading or writing a file, or when doing low-level manipulation
(bitwsire operator, etc.) one shall use explicit integer type
(uint8_t, int16_t, etc.; I tend to prefer this style to u8 and s16 for
two reasons: (1) it is commonly used in other projects, it is
distributed by stdint.h so these types already exist on many platforms
"natively", (2) hey emacs colorize ".*_t" as a type
)
- when one do not really care about the bitsize of the said variable,
then use the "biggest" native typenames, as int for integer, unsigned
int for integer that you know cannot be negative, and double for
floating point numbers.
I think that this particular "rule" matches what you just said:
but lately I start think that using of s16 and uint8_t are bad and
lowers readability of code. I think writing normal short and unsigned
byte are a lot better.
Regarding the second point:
names for class member, functions, variables and so on. We need to
select one style and use it till the end and force new members to use
our style. The first thing to deside is - shal we need type of
variable in variable name. For example:
bool bEnabled = false;
VS
bool enabled = false;
To my view, the type was written once, at variable declaration, and I
find this somehow redundant to "repeat" it at each variable use, and
compilers are able to track the type sufficiently correctly to warn against
an erroneous usage.
Regarding names, we will also have to choose between "case separated"
(MyVariable) and "lower-case, underscore-separated" identifiers
(my_variable). I do prefer using "case separated" identifiers for
classes, and the other style for functions/methods and variable.
Notice that this is just my current preferences, and I just followed
them as there was no "official" coding style yet. I don't know if it
may be relevant, but I follow many of the rules described here:
http://www.doc.ic.ac.uk/lab/cplus/c++.rules/In a more general way, I think that using a "wide-used" coding style
is a good thing. Agreed, I do not have a definition for "wide", but
may be following some GNU guidlines might be good way not to choke
new developpers or potential hackers (in the good sense of the term):
http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/C++STYLE