seraphis-migration / wallet3

Info and discussions about a hypothetical full 'wallet2' rewrite from scratch
MIT License
13 stars 0 forks source link

Should we use any formalized formatting system for comments like Doxygen? #26

Open rbrunner7 opened 2 years ago

rbrunner7 commented 2 years ago

@DangerousFreedom1984 wrote in issue #23:


4) I really want to keep Koe's high standards in writing c++ files and avoid code and design smell. So should we also use Doxygen or something like that to better document the files?


For reference: https://doxygen.nl/

rbrunner7 commented 2 years ago

@UkoeHB answered:


It might be worth a try, but maintaining that would become an ongoing task. I also don't know if the cleaned-up header comment style I'm using will work with Doxygen (iirc they use @param and so on, which is ugly):

/**
* brief: func_name - comment
* type: type - comment   (for templates)
* param: param - comment
* inoutparam: param_inout - comment
* outparam: param_out - comment
* return: comment
*/
template <typename type>
return_type func_name(param_type param, inoutparam_type &param_inout, outparam &param_out);
rbrunner7 commented 2 years ago

@DangerousFreedom1984 's answer to that:


Yeah, on top of the name conventions/organization that you are using, I will try to at least write a few words for each function. It looks better than nothing to me.

rbrunner7 commented 2 years ago

In my experience this "commenting every parameter" style soon degenerates into trivial comments that are pretty much worthless to everybody with even a little understanding of the codebase. Plus, the better the names of the parameters, the less need there is for additional comments, and those names better be good.

There is more: Those comments tend to rot, like koe also hinted at, and may become a net negative if you can't rely on them. Finally they make the header and code files longer and thus less readable.

rbrunner7 commented 2 years ago

I recently had the task to give some advice at the company I work and came up with the following general approach:

When you write comments try to put yourself into the shoes of the reader of your code, using as much "empathy" as you can muster, and ask yourself: Which important facts about the code in question would be the hardest to understand for that reader from looking at the code? What would took them the longest time to understand from merely looking at the code without any support from additional info in the form of comments?

Then comment at least those facts.

There are some candidates for such things that I encounted repeatedly in my own programming:

UkoeHB commented 2 years ago

One thing I'd really appreciate when everyone reviews the seraphis code is to point out confusing points that could benefit from code comments (and also existing code comments that are confusing).