Inline comments are on the same line as the code and should be used sparingly. Sometimes, inline comments can seem necessary, but you can use better naming conventions instead. Here’s an example:
Here, the inline comment does give extra information. However using x as a variable name for a person’s name is bad practice. There’s no need for the inline comment if you rename your variable:
Avoid comments, particularly inline comments, that state the obvious. For example:
It is obvious that x is multipied by 5 so it is not necessary to put it in the comments.