Every now and then I run into questions, initially containing a descriptive block of text that explains the background and experienced problem, followed by a code snippet and eventually a stack-trace if there's a crash.
Usually, these initial descriptive block of texts contains some references to the up-coming code snippets.
For example:
"I'm experiencing a unexpected behavior when calling anObscureMethod() in MyJavaClass.java. I suspect it's due to thisOddVariable, but it might also be..."
Followed by
private class MyJavaClass{
public void anObscureMethod(){
...
}
}
Up until now, I've been suggesting edits to format the initial descriptive text as below.
"I'm experiencing a unexpected behavior when calling anObscureMethod()
in MyJavaClass.java
. I suspect it's due to thisOddVariable
, but it might also be..."
This is in my opinion more readable because it separates the code and gives a better overview of the question as a whole.
The purpose of this question is that I've recently seen posts from more established users, where no such code formatting is present. So I'm simply wondering, is there a policy on this? Is it considered as an individual preference, meaning I should not be suggesting these kinds of edits?