The Code Style Rules Worth Arguing About
My first code review argument was about a brace. Same line or next line. A senior developer had opened my pull request, scrolled to a method I was proud of, and left a single comment: "brace style." Two hours of back-and-forth later, the code was unchanged, both of us were annoyed, and I had learned nothing about the system I was supposed to be shipping. I have since sat in that argument from the…
The author recounts their first code review argument over a single brace placement, which left both parties annoyed and with no increased understanding of the system. In the years since, they have categorized code style arguments into three buckets. The first bucket includes rules with observable consequences, like placing each statement and declaration on its own line.
The second bucket comprises purely stylistic preferences, such as whether to use spaces or tabs. The third bucket contains rules that cannot be settled by a code formatter, focusing on aspects like method responsibilities, naming conventions, and boundary conditions. The author concludes that the time spent arguing about tasteless rules could be better spent addressing more critical issues.
They recommend automating the taste bucket through a shared formatter configuration, arguing about the third bucket, and documenting the first bucket's rules to streamline code reviews and improve productivity.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.