Note: This is something only programmers are going to get. If you're not a programmer and you're really curious, look it up on Wikipedia.
I've been getting more and more frustrated with my employer's use of K&R throughout all of the code that I'm expected to maintain. It's silly. It's stupid. I shouldn't let it get to me.
But any time I see it... I just have to change it. I can't stop myself. Maybe I need help, or a twelve-step program for Allman junkies.
Oh, yeah... and he never puts spaces between operands and operators. Ever.
Just had to vent....
Posts: 293 | Registered: Jun 2004
| IP: Logged |
As I said, pretty trivial. It's just a question of where you put that opening brace. Nonetheless, brace styles have sparked many a holy war between coders who might otherwise be able to co-exist in peace and harmony.
I.iYea, Verily, said the Great Allman, Thine opening and closing braces shall line up, and the code that thou dost write shall be indented between them.ii And there was a great cheer from the coders huddled there, for they saw that this was good. iiiWoe be unto him who writeth his code with the opening brace on the same line as the control statement, for this is folly and leadeth to many headaches. ivVerily I say unto thee, said the Allman, there shall come coders who practice the ways of evil,vand they shall write their control statements with many characters, such that the end of the statement falleth off the edge of thy screen, and the opening brace shall thusly be hidden from you.viDo not be like those foul tricksters, but instead shalt thou write maintainable code.vii And there was much rejoicing.
Posts: 293 | Registered: Jun 2004
| IP: Logged |
posted
For properly indented code, K&R style is much more readable, IMO.
But its not like you can't set up your editor to switch to Allman style, and then switch it back to K&R style before you commit if your employers insist on it.
Posts: 15770 | Registered: Dec 2001
| IP: Logged |