5 ms·
The code formatter doesn't know anything about the author's intend. If it removes empty lines that were added to visually separate blocks of code, that's just
by clktmr 7y ago
The code formatter doesn't know anything about the author's intend. If it removes empty lines that were added to visually separate blocks of code, that's just annoying.
- ozim 7y agoThere is value in having consistent code, like quickly scanning it by other people and finding quickly common flaws. Everything above, like trying to convey some special intent, falls under "law of dimnishing returns". Better to write a comment, because other team mates probably will not understand your intent expresed with spacing.
- clktmr 7y agoThat's what I meant by pleasing the code formatter. We all have seen those horrible codebases filled with linter-disabling comments. This is what happens if the rules are too strict. Also, code is already consistent by it's syntax. I can't think of any example how this strict formatting helps anyone.
- ozim 7y agoBut you don't disable linter, you just accept the way it is :) just let it go. No disabling linter comments allowed, if you want to say this block of code is special in some way do normal comment describing why it is special.
- alexeiz 7y ago> There is value in having consistent code, like quickly scanning it by other people and finding quickly common flaws. Does that make up for the constant annoyance of having automatic formatter screwing up your code? Depends on how much code you write, I guess. If you write code a lot, you'd rather have your code retain the original formatting and put up with reading the code of others in their formatting style. This is not such a big deal, btw. A professional developer should be able to comprehend code in regardless of formatting (unless it's truly horrible, of course). I notice that people who insist on mandatory use of code formatters don't actually write code that much. So they don't care that their code gets reformatted.
- thedufer 7y ago> I notice that people who insist on mandatory use of code formatters don't actually write code that much. So they don't care that their code gets reformatted. This feels completely made up. As a reader of code, auto formatting makes my job slightly better due to consistency. As a writer it's a huge improvement. Not needing to think about where to put newlines and the like lets me focus on what actually matters. My experience is similar to the author's - most people who are against code formatters change their tune quickly if you can convince them to try it.
- gdfasfklshg4 7y agoI write lots of code and I love the auto-formatter... I especially love it when working on a project with a few different developers that used an auto-formatter.
- Aeolun 7y agoYou can generally tell the auto-formatter to ignore extra lines of code. Most of the things that get covered by a formatter are eminently sensible.
- clktmr 7y agoFrom what I did understand, that's not what the author of the article meant. He wants to enforce a style that guarantees exactly how the file is formatted.