EDIT: An edit dispute answered by rolfl is related, but dates back to 2015 and was answered by one moderator. I feel like there should be an official verdict.
This applies to edits/questions in general, but the question came to me after reviewing edits.
Lets say a user wants a review on this code:
Initial Code
public class MyProgram{
public static void main(String[] args){
int myNumber=10;
int mySecondNumber=20;
int myNewNumber=myNumber+mySecondNumber;
System.out.println( myNewNumber );
}
}
Now understandably, to help reviewers, we can edit the question with indents to make the code more readable:
First Edit
public class MyProgram{
public static void main(String[] args){
int myNumber=10;
int mySecondNumber=20;
int myNewNumber=myNumber+mySecondNumber;
System.out.println( myNewNumber );
}
}
This seems to be a common edit for new users and hard-to-read code.
Now lets say another user comes along, and applies this edit:
Second Edit
public class MyProgram {
public static void main(String[] args) {
int myNumber = 10;
int mySecondNumber = 20;
int myNewNumber = myNumber + mySecondNumber;
System.out.println(myNewNumber);
}
}
This edit spaces out all the operators and variable assignments and removes the space in the println
function call.
Q: Is an edit fixing spacing (not indentation) allowed?
Reasoning
To some programmers, they use the code style of the result of the First Edit
. The Initial Code
indentation could have been messed up from a copy paste, so that edit seems acceptable. However, beginner programmers might not/probably don't know about the best practices to follow in order to write neat, readable code. I feel there is more value commenting on the spacing in an answer, not in an edit. This way, the answerer can provide explanation as to why to follow that practice, instead of the poster wondering why their code was edited.