Only want to ever see Allman style code and save K&R style code

前端 未结 3 1572
猫巷女王i
猫巷女王i 2021-02-02 09:17

One of our developers decided he\'d dictate to other developers how people should format their source code.

Myself, I\'m a firm believer that Allman style indentation is

3条回答
  •  时光说笑
    2021-02-02 09:45

    With all due respect to Mike, if you can't beat them, join them. Indeed, learn to tolerate ugliness, as djna has advised. I give this advice after having spent an entire career quietly fighting this battle.

    I believe that Allman-style coding is better in several meaningful, significant ways, starting with code alignment and visibly clarifying blocks of code. Allman-style people tend to be those that favor/tolerate more use of vertical whitespace to help clarify which things go together and when a new step or phase has begun.

    From my own anecdotal research, the main advantage to K&R most often cited, other than homage to earlier precedent, is that K&R is a style favored by those that like to see more code on one screen. Yes, it is true, that's the main reason. Code density. I thought this issue would have died its final death once we got past the age of 80 x 25 character console screens in the early 90's, but alas, but it seems not to have mattered. So for those that like code density so they can see more code on one screen at a time, we suffer with millions of lines of K&R style code. * Sigh *

    Bottom line: You can't win a religious war. It's not worth the effort. When in Rome, do as the Romans do and just learn to live with what is. This is an issue that strikes us psychologically, because it is kind of about Power and Control. But we all understand that some things we simply don't have legitimate power or control over, so let those things be and learn to adapt. That is truly the right way to approach your software development career.

提交回复
热议问题