1

I have come across a lot of new users posting code that does not follow naming conventions. For example code like

public class myclass{
int myint;
String myimportantword;
void method dothisreallycomplicatedprocess(){}
}

As you can see, the code is hard to read.

  • Should we just auto correct it?

    or

  • Should we post a comment letting the user know what the naming conventions are?

  • 1
    • 3
      Doesn't follow the naming conventions of who? Unless I specifically asked or was being paid to code in a certain way, I wouldn't want my coding style changed. Commented Aug 18, 2014 at 19:57

    1 Answer 1

    10

    Well...

    If it's code in a question, leave it. That's their convention, but you can point out the appropriate conventions in a comment, or even in an answer to their question.

    If it's code in an answer, it depends. If you're only modifying the answer to be more readable with respect to modern Java conventions, and you don't change any of the logic itself, then it's an edit I'd be okay with. Although, I'd also strongly encourage you to find more stuff to edit, too.

    If the code is the only thing you edit...please don't. If there are other glaring typos in the actual answer, then fix those too.

    1
    • 1
      Suggesting an edit to an answer correcting code is usually rejected as "invalid edit". It's generally better to not make people review things that require domain-specific knowledge.
      – bjb568
      Commented Jun 8, 2014 at 7:21

    You must log in to answer this question.

    Not the answer you're looking for? Browse other questions tagged .