Comments

Comments can get hazy and a little more hazy depending on the program you are using. I would really appreciate it if all coders follow these standards for commenting code.

First things first are single line comments. Please don't put pointless comments When I mean by pointless comments are comments that are obviously explaining nothing and is already view able by the code itself no explanation. Those comments just take up space, aren't funny and just bother the reader because it's quite obvious what the coder is doing. It's okay to put comments right above the line of code you want to comment, if you feel as if it's more readable.

EXCEPTION: The occasional funny joke is allowed, as long as it's not too distracting and replacing actual important comments. I am probably the biggest offender of this.

Comments should try to describe the why of the code, while the how should be pretty self explanatory from good coding. If you need to describe how the code works in comments, consider simplifying it or refactoring it.

Multi line comments are mainly used for functions, classes, structs, really important stuff and beginning of files.

Every function and class you write should have a JavaDoc-like comment documenting:

  • Parameters

  • Return value

  • Exceptions thrown

  • Preconditions/postconditions of params

  • Behavior of function

Last updated