wakaama
wakaama copied to clipboard
Define code styling rules
Maybe it would be good to define some rules about code styling ? This could help to have a more consistent code base ?
The rules could be written in a wiki page (e.g. https://github.com/eclipse/leshan/wiki/Code-&-design-guidelines)
-
value == var
VSvar == value
(currently leaning towards :value == var
?) -
if (ptr)
VSif(ptr != NULL)
(currently leaning towards :if(ptr != NULL)
?)
E.g of question :
Should we write value == var
or var == value
(see https://github.com/eclipse/wakaama/pull/512#discussion_r544283993 for more details) ?
About benefits of value == var
, this is maybe not so true.
@sbertin-telular, @tuve, @qleisan, @rettichschnidi ?
I'd split this into two parts:
- Code formatting: using e.g. clang-format (not part of this issue)
- Everything else (including the example from above): Lets find something which is a) close to the predominantly used style in this code base (is there one?) and b) is already existing
As far as value == var
or var == value
, I find var == value
slightly easier to read and write as it aligns with the way I think. I have been working on a project recently with value == var
as the standard, so I'm getting used to it, but it does still take a bit of extra time to write or read it that way.
(I'm not sure be I think you have right to create wiki page if needed)
Add a new code style question : if (ptr)
VS if(ptr != NULL)
(from #512)
I will add all this kind of question in the issue description :point_up:
Decide coding style for when to check pointers https://github.com/eclipse/wakaama/issues/514#issuecomment-761041820 https://github.com/eclipse/wakaama/issues/506#issue-752058734
"always check for runtime errors but not always for programming errors...". This needs to be refined but IMHO it doesn't make sense to ALWAYS check pointers everywhere. "Assert" in combination with testcoverage is another tool that we can use to keep the code lean and clean. Some (Donald Knuth et al. :) argue that crash early and crash big is far better than creating wrong data...
Question about usage of assert
: https://github.com/eclipse/wakaama/pull/531