Should I leave in documentation in code for review?

I'm surprised I can't find this as a question already, so I'm taking a shot and posting...

I document my code. I don't not document my code before considering myself done for the day. Most of the code posted here lacks documentation, and I'm trying to determine if it's an unofficial practice to strip things like doxygen comments or if it's simply undocumented code.

In short: Is it a best practice to include things like function documentation and inline comments when posting code for review?

• Always include everything as it is for the review. What is documentation though? programmers.stackexchange.com/a/254979/125931 – Raystafarian Jul 11 '18 at 6:30
• @Raystafarian Thank you for the link. It bears reminding that self-documenting code with a short description is better than a thousand words of explanation and some spaghetti code. – Jon Harper Jul 11 '18 at 11:42
• 1) Personally I leave the documentation in, having the right amount of comments (i.e., documenting things you should, without describing the code to the point where you are creating a bigger maintenance burden) can be tricky to master and I like to hear people's feedback on that, 2) When I include comments for CR reviewers only (e.g., directing them to something) I've done something like //@CR: Would you rather I wrote this using <method X> instead? – jrh Jul 13 '18 at 19:05

Is it a best practice to include things like function documentation and inline comments when posting code for review?

If you normally document your code, then include the documentation when posting here.

If you normally don't document your code, then don't add documentation just for the sake of posting it here.

We prefer to see the code as it was written.

It is however a good idea to make a self-review of your code before posting it here, and if you during that step find out that documentation is missing, well... then add some.

• That's well put and a fair point. – Jon Harper Jul 9 '18 at 10:34
• Since this is from a mod, I'm going to accept. – Jon Harper Jul 9 '18 at 10:38

Going purely from subjective impressions and without actually checking them, quite a lot of my answers specifically point out parts of the code which I think are underdocumented. There are at least two good reasons for leaving the documentation in:

1. We want to review your actual code, not a sanitised version of it. Otherwise we might waste our time suggesting improvements which were already present in the real code.
2. The better we understand your code, the more specific we can be in our reviews.
• I admit this is the consensus I hope the community agrees upon, despite what it says about general documentation habits among programmers. – Jon Harper Jul 9 '18 at 10:32
• And perhaps 3. We might spot an error in the comments. – Andrew Morton Jul 12 '18 at 15:43
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.22112929821014404, "perplexity": 1316.7987951802636}, "config": {"markdown_headings": false, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-26/segments/1560627998325.55/warc/CC-MAIN-20190616222856-20190617004856-00511.warc.gz"}