Braces
-
That's probably how K&R started, so people then thought it was the right way to do it.
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing.Agreed.
-
No, not orthodonture. Has anyone else noticed that Microsoft has reformatted all of their online documentation to use K&R style braces instead of Allman style? I personally prefer the previous (Allman) style.
The difficult we do right away... ...the impossible takes slightly longer.
I always preferred K&R when I worked on small screens, because I could see more code at once. now that I have huge screens, I like Allman better, because the braces line up. The guy with the fashionable little laptop must have won the battle.
-
Well, I think it's important to remember that coding styles are personal preferences and opinions. Although I also prefer the BSD style I must admit.... being exposed to several styles increases my code comprehension levels. Here is a very old survey from the 7th of May 2012 with my comments on the subject. Do you have a coding style?[^] Best Wishes, -David Delaune
Totally correct. There is the Allman style and everything else. I am so retentive about this, I surround single line indented lines like this. if (foo) { single_line(); } Sometimes real world function get longer than will fit on one or even two screens. Being able to clearly see and understand the organization of a complicated bit of logic makes it more likely the code is doing what you actually wanted it to do. And don't get me started on Hungarian notation. I guess if you are coding on paper or a chalkboard it makes sense. Otherwise, what a ridiculous concept.