Braces
-
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.
Curiously, the actual header file itself use the Allman style. The curious part being it was changed for the documentation.
typedef struct addrinfoW
{
int ai_flags; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST
int ai_family; // PF_xxx
int ai_socktype; // SOCK_xxx
int ai_protocol; // 0 or IPPROTO_xxx for IPv4 and IPv6
size_t ai_addrlen; // Length of ai_addr
PWSTR ai_canonname; // Canonical name for nodename
_Field_size_bytes_(ai_addrlen) struct sockaddr * ai_addr; // Binary address
struct addrinfoW * ai_next; // Next structure in linked list
}
ADDRINFOW, *PADDRINFOW;"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
-
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.
Allman style. I only do K&R for java-script.
-
Curiously, the actual header file itself use the Allman style. The curious part being it was changed for the documentation.
typedef struct addrinfoW
{
int ai_flags; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST
int ai_family; // PF_xxx
int ai_socktype; // SOCK_xxx
int ai_protocol; // 0 or IPPROTO_xxx for IPv4 and IPv6
size_t ai_addrlen; // Length of ai_addr
PWSTR ai_canonname; // Canonical name for nodename
_Field_size_bytes_(ai_addrlen) struct sockaddr * ai_addr; // Binary address
struct addrinfoW * ai_next; // Next structure in linked list
}
ADDRINFOW, *PADDRINFOW;"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
Well, Historically the employees that write the MSDN documentation are not FTE (Blue) but V-dash or A-dash[^] employees. The contribution they make is very much appreciated but they usually have restricted access to resources and source code. The documentation reflects that. Recently there has been an internal push for some dedicated FTE and resource allocations dedicated to documentation.
-
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.
-
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.
Seems to be language dependent. C# is all Allman as far as I can see.
Wrong is evil and must be defeated. - Jeff Ello
-
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.
-
Well, everything else has been fixed already, so that was the next item they had to deal with...
Yeah, after fixing all the icons, what is there left to do?
The difficult we do right away... ...the impossible takes slightly longer.
-
Allman makes the braces easy to match up. But more importantly, it makes conditions easy to read because the left brace is alone on the following line. Most styles squander horizontal space but are miserly when it comes to vertical space.
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing.That is because readability becomes less important when publishing. Vertical space means $$$, so it trumps readability.
-
That is because readability becomes less important when publishing. Vertical space means $$$, so it trumps readability.
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. -
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.