<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: To Brace or not to Brace in C# ifs and other Constructs</title>
	<atom:link href="http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/feed/" rel="self" type="application/rss+xml" />
	<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/</link>
	<description>Specializing in Microsoft Web and Database Technologies</description>
	<lastBuildDate>Sun, 14 Mar 2010 20:45:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Why I Love the Semicolon! &#124; PeterKellner.net</title>
		<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/comment-page-1/#comment-25516</link>
		<dc:creator>Why I Love the Semicolon! &#124; PeterKellner.net</dc:creator>
		<pubDate>Sat, 24 Oct 2009 15:23:59 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/#comment-25516</guid>
		<description>[...] so we all want to be somewhat popular, and it seems that my last article, “To Brace Or Not to Brace”, seems to have gotten a lot of attention, so, here goes my opinion on the popular semi-colon [...]</description>
		<content:encoded><![CDATA[<p>[...] so we all want to be somewhat popular, and it seems that my last article, “To Brace Or Not to Brace”, seems to have gotten a lot of attention, so, here goes my opinion on the popular semi-colon [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mongo lloyd</title>
		<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/comment-page-1/#comment-25509</link>
		<dc:creator>mongo lloyd</dc:creator>
		<pubDate>Fri, 23 Oct 2009 09:17:55 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/#comment-25509</guid>
		<description>I agree with always using braces*, mostly because if I don&#039;t, whenever I realise I have to do more than just one statement after an if (or within a for/while, etc), I have to actually reformat the code. Inserting brackets is a bit annoying to have to do. It&#039;s not just a one-keystroke move (unless you have a really intelligent editor). 

Should the code actually have to be reformatted for such a simple and common code change? I think not.


*: Except for in case blocks, where I think it is really daft and pointless. One of my pet peeves actually.</description>
		<content:encoded><![CDATA[<p>I agree with always using braces*, mostly because if I don&#8217;t, whenever I realise I have to do more than just one statement after an if (or within a for/while, etc), I have to actually reformat the code. Inserting brackets is a bit annoying to have to do. It&#8217;s not just a one-keystroke move (unless you have a really intelligent editor). </p>
<p>Should the code actually have to be reformatted for such a simple and common code change? I think not.</p>
<p>*: Except for in case blocks, where I think it is really daft and pointless. One of my pet peeves actually.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andyclap</title>
		<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/comment-page-1/#comment-25498</link>
		<dc:creator>andyclap</dc:creator>
		<pubDate>Thu, 22 Oct 2009 10:31:40 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/#comment-25498</guid>
		<description>Most of the problems solved by consistently bracing single lines are also solved with a code beautifier.

The additional benefits of beautification (consistency, SCM diff) are enough to warrant including beautification as part of the dev process.

Now ... does anybody know a beautifier as good as R# that can be invoked through nAnt?</description>
		<content:encoded><![CDATA[<p>Most of the problems solved by consistently bracing single lines are also solved with a code beautifier.</p>
<p>The additional benefits of beautification (consistency, SCM diff) are enough to warrant including beautification as part of the dev process.</p>
<p>Now &#8230; does anybody know a beautifier as good as R# that can be invoked through nAnt?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian</title>
		<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/comment-page-1/#comment-25495</link>
		<dc:creator>Ian</dc:creator>
		<pubDate>Wed, 21 Oct 2009 14:19:17 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/#comment-25495</guid>
		<description>I use resharper to force {} everywhere possible. I have been bitten too many times by people that write multi-line statements, but forget to add the braces. It can be quite difficult to track down these kinds of bug. I also use CodeKana which gives me a mental image of my code structure without needing to read the code (works very nicely with the {} in the code).</description>
		<content:encoded><![CDATA[<p>I use resharper to force {} everywhere possible. I have been bitten too many times by people that write multi-line statements, but forget to add the braces. It can be quite difficult to track down these kinds of bug. I also use CodeKana which gives me a mental image of my code structure without needing to read the code (works very nicely with the {} in the code).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Juozas</title>
		<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/comment-page-1/#comment-25494</link>
		<dc:creator>Juozas</dc:creator>
		<pubDate>Wed, 21 Oct 2009 13:58:54 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/#comment-25494</guid>
		<description>My rule of thumb is: always use braces, except when all you do is return, e.g:

if (param == null)
    return false;

This rule has exceptions - if condition is complex, I use braces even for simple return statement. And I NEVER write statements in condition line.</description>
		<content:encoded><![CDATA[<p>My rule of thumb is: always use braces, except when all you do is return, e.g:</p>
<p>if (param == null)<br />
    return false;</p>
<p>This rule has exceptions &#8211; if condition is complex, I use braces even for simple return statement. And I NEVER write statements in condition line.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/comment-page-1/#comment-25493</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Wed, 21 Oct 2009 13:19:15 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/#comment-25493</guid>
		<description>@Giraffe and @David:  I would write it the short way, but was just making a point about it does get uglier and is that worth it.</description>
		<content:encoded><![CDATA[<p>@Giraffe and @David:  I would write it the short way, but was just making a point about it does get uglier and is that worth it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giraffe</title>
		<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/comment-page-1/#comment-25492</link>
		<dc:creator>Giraffe</dc:creator>
		<pubDate>Wed, 21 Oct 2009 09:17:36 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/#comment-25492</guid>
		<description>@David,

I think rather that you should be comparing

if (myObject1==null) err = “bad1″;
if (myObject2==null) err = “bad2″;

with

if (myObject1==null) { err = “bad1″; }
if (myObject2==null) { err = “bad2″; }</description>
		<content:encoded><![CDATA[<p>@David,</p>
<p>I think rather that you should be comparing</p>
<p>if (myObject1==null) err = “bad1″;<br />
if (myObject2==null) err = “bad2″;</p>
<p>with</p>
<p>if (myObject1==null) { err = “bad1″; }<br />
if (myObject2==null) { err = “bad2″; }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Garry Pilkington</title>
		<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/comment-page-1/#comment-25491</link>
		<dc:creator>Garry Pilkington</dc:creator>
		<pubDate>Wed, 21 Oct 2009 08:31:48 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/#comment-25491</guid>
		<description>I agree with you, it makes the code much easier to read and understand. However as soon as I put any else statements in there I judge whether it would look neater using a conditional operator. I always believe that code should be firstly understood by a human, the compiler doesn&#039;t really care either way.</description>
		<content:encoded><![CDATA[<p>I agree with you, it makes the code much easier to read and understand. However as soon as I put any else statements in there I judge whether it would look neater using a conditional operator. I always believe that code should be firstly understood by a human, the compiler doesn&#8217;t really care either way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Kemp</title>
		<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/comment-page-1/#comment-25489</link>
		<dc:creator>David Kemp</dc:creator>
		<pubDate>Wed, 21 Oct 2009 08:26:29 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/#comment-25489</guid>
		<description>so you&#039;re saying

if (myObject1==null)
{
 err = &quot;bad1&quot;;
}
if (myObject2==null) 
{
 err = &quot;bad2&quot;;
}

is more readable than

if (myObject1==null) err = &quot;bad1&quot;;
if (myObject2==null) err = &quot;bad2&quot;;

Have you lost your mind?

You&#039;ll be telling me I can only have one &quot;return&quot; statement per function next!</description>
		<content:encoded><![CDATA[<p>so you&#8217;re saying</p>
<p>if (myObject1==null)<br />
{<br />
 err = &#8220;bad1&#8243;;<br />
}<br />
if (myObject2==null)<br />
{<br />
 err = &#8220;bad2&#8243;;<br />
}</p>
<p>is more readable than</p>
<p>if (myObject1==null) err = &#8220;bad1&#8243;;<br />
if (myObject2==null) err = &#8220;bad2&#8243;;</p>
<p>Have you lost your mind?</p>
<p>You&#8217;ll be telling me I can only have one &#8220;return&#8221; statement per function next!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #459</title>
		<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/comment-page-1/#comment-25488</link>
		<dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #459</dc:creator>
		<pubDate>Wed, 21 Oct 2009 07:26:09 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/#comment-25488</guid>
		<description>[...] To Brace or not to Brace in C# ifs and other Constructs - Peter Kellner asks one of the great coding style questions of all time, &#8216;do I have to use braces with that?&#8217; [...]</description>
		<content:encoded><![CDATA[<p>[...] To Brace or not to Brace in C# ifs and other Constructs &#8211; Peter Kellner asks one of the great coding style questions of all time, &#8216;do I have to use braces with that?&#8217; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bart  Czernicki</title>
		<link>http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/comment-page-1/#comment-25487</link>
		<dc:creator>Bart  Czernicki</dc:creator>
		<pubDate>Tue, 20 Oct 2009 23:29:51 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/10/19/codingstandards-csharp-braces/#comment-25487</guid>
		<description>could be cleaner with the ternary operator:

myObject1 == null ? err = &quot;bad1&quot; : err = &quot;something else&quot;;

Many people code in multiple languages and even in SQL writing code like this can get you in trouble:

if (@someVariable is NULL)
   err = &quot;bad&quot;1
   err2 = &quot;bad also&quot;

err2 would not be under the condition and should have the begin/end (curly bracket equivelant in c#).  So sticking to general good practices is a good idea.</description>
		<content:encoded><![CDATA[<p>could be cleaner with the ternary operator:</p>
<p>myObject1 == null ? err = &#8220;bad1&#8243; : err = &#8220;something else&#8221;;</p>
<p>Many people code in multiple languages and even in SQL writing code like this can get you in trouble:</p>
<p>if (@someVariable is NULL)<br />
   err = &#8220;bad&#8221;1<br />
   err2 = &#8220;bad also&#8221;</p>
<p>err2 would not be under the condition and should have the begin/end (curly bracket equivelant in c#).  So sticking to general good practices is a good idea.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
