To view parent comment, click here.
To read all comments associated with this story, please click here.
Yeah I'm aware of that and I don't agree with it. I think it's less readable and the opposite of what developers in most other C-derived languages prefer.
Plus I object to Microsoft dictating how I -or any other 3rd party developer- chooses to format the braces in our own source code. That's my prerogative, not theirs.
Edited 2013-01-16 14:21 UTC
Well it is a matter of taste, so I tend to adopt what the language creators recommend, in this case Microsoft.
Well they firstly aren't, they are a set of suggested guidelines.
While I agree it is personal taste, pretty much all C# books, examples and third party libraries use that bracing style. Also Visual Studio and StyleCop default to type of bracing. It is what other C# programmers expect to see. I don't see any benefit in bucking the trend in the community, but as I said it is personal choice.
As I say, when I am doing Java or JavaScript I use the bracing style that you suggest. Java because it is what Sun recommended and JavaScript because of the issues with Semi-colon insertion.
Edited 2013-01-16 14:43 UTC
I usually put braces on a new line unless the block is one line long.
if (someArg == null)
throw new ArgumentNullException("someArg");
The only exception I usually have to this is if its part of a larger if-the-else statement and the other blocks are multiline and have curly braces. Then I think:
if (this == that)
doX();
else if (x == y)
{
// ..
}
else
{
// ..
}
I think the obsession with vertical space is kind of silly in this day and age. I am much more sensitive to code that sprawls horizontally forever.
Besides, I often find new line braces more readable while less compact, whereas the opposite is true for a lack of braces, same line braces, or first brace same line.
At the end of the day though, it is extremely annoying when some full-of-himself programmer ignores the established project coding guidelines. I don't care if a monkey wrote it, if I'm going to be a part of a team, I'm going to follow their rules.
I hear you on that.
In the past I've written code that I've personally hated but it was correct in the context of the wider project.
That said, I have been known to completely rewrite smaller projects before, but those have been extreme circumstances (and there's usually been more wrong than just the use of blocks and braces hehe)
if (someArg == null)
throw new ArgumentNullException("someArg");
I usually like putting the braces.
Here here, we are having a meeting about coding standards just because there isn't any in our team.
I would like to make sure we use the Microsoft ones for C#, just because they are easily referenced and are well known. Also because we have a lot of juniors, when they look at code samples they are normally using the Microsoft syntax for the most part.





Member since:
2009-08-18
Actually apart from the lack of indentation it was correct. The Visual Studio default and the Microsoft Recommended Coding conventions all use that style.
http://blogs.msdn.com/b/brada/archive/2005/01/26/361363.aspx