What is the best way to post comments in code? I see at least three different ways:
1:
int i = 10; //Set i to 10
2:
//Set i to 10
int i = 10;
3:
int i = 10;
//Set i to 10
The disadvantage of using the first method is that many people use tabs instead of spaces, and this will lead to comments becoming very inconsistent when resizing the tab.
The second and third fragments eliminate this problem, but if there is a lot of code, it is sometimes unclear which line the comment refers to.
source
share