Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><b>Any code style that makes you reorder things when code changes is bad.</b></p> <p>It would screw up diffs. You are using a version control system right?</p> <p>There's a few other things that would make your code prettier, but screw up diffs.</p> <p>Imagine this code:</p> <pre><code>int foo = 42; int fooBar = 1024; </code></pre> <p>Now let's make it prettier by lining up the = signs:</p> <pre><code>int foo = 42; int fooBar = 1024; </code></pre> <p>But then we add another variable:</p> <pre><code>int foo = 42; int fooBar = 1024; String nowLetsBeEvil = 6400; </code></pre> <p>Now if you did a diff, all 3 lines have changed, when only the last one did.</p> <p><b>And there's more, lining up params between methods is bad</b></p> <pre><code>sqrt(x + y, x - z); sqrt(x , x ); </code></pre> <p>The comma and semi-colon are nicely lined up, but if you ever change the code, you'll have to manually reformat all the sqrt lines that are together and <b>screw up the diffs</b> again.</p> <p>Basically, never do manual formatting. Always enforce code styles using an IDE or pretty printer. <b>But also never choose a code style where the format will change when your code did not</b></p> <p>EDIT:</p> <p>As stated in the comments, some diff tools can ignore whitespaces within lines. This is great, but not all diff tools can do this. If you are aligning fields or params, make sure you are:</p> <ol> <li>Not doing it manually</li> <li>Your diff tool can ignore the whitespace changes</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload