<?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>BUY Adefovir ONLINE WITHOUT PRESCRIPTION</title>
	<atom:link href="http://elegantcode.com/2009/04/09/conditional-using/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2009/04/09/conditional-using/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=conditional-using</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>BUY Adefovir ONLINE WITHOUT PRESCRIPTION</title>
		<link>http://elegantcode.com/2009/04/09/conditional-using/comment-page-1/#comment-45321</link>
		<dc:creator>Tony Rasa</dc:creator>
		<pubDate>Sat, 11 Apr 2009 00:11:08 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/04/09/conditional-using/#comment-45321</guid>
		<description>Yeah but the braces masochism came from C, where implicit braces were built into the language - and quickly became an awesome source of the best sorts of hard to find bugs.  It became an anti-pattern, for a good reason.

True, we have things better now, with IDEs and tools that will help catch problems.  But still, to me, leaving off the outer {}s for the using block strikes me a just being clever to prove a point.  Who cares about two extra lines of brace, vs. the risk of subtle bugs and confusing the cow orkers who follow you?</description>
		<content:encoded><![CDATA[<p>Yeah but the braces masochism came from C, where implicit braces were built into the language &#8211; and quickly became an awesome source of the best sorts of hard to find bugs.  It became an anti-pattern, for a good reason.</p>
<p>True, we have things better now, with IDEs and tools that will help catch problems.  But still, to me, leaving off the outer {}s for the using block strikes me a just being clever to prove a point.  Who cares about two extra lines of brace, vs. the risk of subtle bugs and confusing the cow orkers who follow you?</p>
]]></content:encoded>
	</item>
	<item>
		<title>BUY Adefovir ONLINE WITHOUT PRESCRIPTION</title>
		<link>http://elegantcode.com/2009/04/09/conditional-using/comment-page-1/#comment-45311</link>
		<dc:creator>Jan Van Ryswyck</dc:creator>
		<pubDate>Fri, 10 Apr 2009 15:23:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/04/09/conditional-using/#comment-45311</guid>
		<description>I&#039;m starting to get more and more annoyed by the braces masochism that the C# compiler enforces. This is probably why I ended up with this code. The code inside the using is only executed when the if statements evaluates to true. Maybe its time for me to evaluate some other languages?</description>
		<content:encoded><![CDATA[<p>I&#8217;m starting to get more and more annoyed by the braces masochism that the C# compiler enforces. This is probably why I ended up with this code. The code inside the using is only executed when the if statements evaluates to true. Maybe its time for me to evaluate some other languages?</p>
]]></content:encoded>
	</item>
	<item>
		<title>BUY Adefovir ONLINE WITHOUT PRESCRIPTION</title>
		<link>http://elegantcode.com/2009/04/09/conditional-using/comment-page-1/#comment-45310</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Fri, 10 Apr 2009 14:38:26 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/04/09/conditional-using/#comment-45310</guid>
		<description>I&#039;m not a fan of being clever for the sake of being clever.  I prefer the much more explicit and boring:

using(var userEntry = GetUserEntryFor(userName))
{
    if(userEntry != null)
    {        
        // Do something with userEntry
    }
}

Everyone (should) knows what the above means.  From the comments what you did confused some people.

If at some point the test for userEntry becomes more complex maybe a method is warrented.  But the test should always be inside the explicitly braced using block.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not a fan of being clever for the sake of being clever.  I prefer the much more explicit and boring:</p>
<p>using(var userEntry = GetUserEntryFor(userName))<br />
{<br />
    if(userEntry != null)<br />
    {<br />
        // Do something with userEntry<br />
    }<br />
}</p>
<p>Everyone (should) knows what the above means.  From the comments what you did confused some people.</p>
<p>If at some point the test for userEntry becomes more complex maybe a method is warrented.  But the test should always be inside the explicitly braced using block.</p>
]]></content:encoded>
	</item>
	<item>
		<title>BUY Adefovir ONLINE WITHOUT PRESCRIPTION</title>
		<link>http://elegantcode.com/2009/04/09/conditional-using/comment-page-1/#comment-45309</link>
		<dc:creator>Nair</dc:creator>
		<pubDate>Fri, 10 Apr 2009 14:11:03 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/04/09/conditional-using/#comment-45309</guid>
		<description>I didn&#039;t know you could use &#039;if&#039; with &#039;using&#039; How does it evaluate? The instanace get checked first before going into the code block? so if is allowed, what else can you do with using? I never seen this code before. Thanks for the tip.</description>
		<content:encoded><![CDATA[<p>I didn&#8217;t know you could use &#8216;if&#8217; with &#8216;using&#8217; How does it evaluate? The instanace get checked first before going into the code block? so if is allowed, what else can you do with using? I never seen this code before. Thanks for the tip.</p>
]]></content:encoded>
	</item>
	<item>
		<title>BUY Adefovir ONLINE WITHOUT PRESCRIPTION</title>
		<link>http://elegantcode.com/2009/04/09/conditional-using/comment-page-1/#comment-45306</link>
		<dc:creator>Dew Drop - April 10, 2009 &#124; Alvin Ashcraft's Morning Dew</dc:creator>
		<pubDate>Fri, 10 Apr 2009 11:56:19 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/04/09/conditional-using/#comment-45306</guid>
		<description>[...] Conditional Using (Jan Van Ryswyck) [...]</description>
		<content:encoded><![CDATA[<p>[...] Conditional Using (Jan Van Ryswyck) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>BUY Adefovir ONLINE WITHOUT PRESCRIPTION</title>
		<link>http://elegantcode.com/2009/04/09/conditional-using/comment-page-1/#comment-45304</link>
		<dc:creator>Jan Van Ryswyck</dc:creator>
		<pubDate>Fri, 10 Apr 2009 10:00:21 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/04/09/conditional-using/#comment-45304</guid>
		<description>Sry, guys, no extension methods. I&#039;m targeting .NET 2.0 here. 

@Chris: The code you showed is what I had at first. But I had several DirectoryEntry objects that way, so I found this syntax to be more compact but still readable.</description>
		<content:encoded><![CDATA[<p>Sry, guys, no extension methods. I&#8217;m targeting .NET 2.0 here. </p>
<p>@Chris: The code you showed is what I had at first. But I had several DirectoryEntry objects that way, so I found this syntax to be more compact but still readable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>BUY Adefovir ONLINE WITHOUT PRESCRIPTION</title>
		<link>http://elegantcode.com/2009/04/09/conditional-using/comment-page-1/#comment-45292</link>
		<dc:creator>Bob The Janitor</dc:creator>
		<pubDate>Thu, 09 Apr 2009 22:52:01 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/04/09/conditional-using/#comment-45292</guid>
		<description>I like the David&#039;s Idea of doing a null check extender, something like this

public static bool IsNotNull(this T myObject)
{
       return myObject != null;
}

vs the CouldBeFound method, then you have a not null for everything, and it&#039;s nice and readable</description>
		<content:encoded><![CDATA[<p>I like the David&#8217;s Idea of doing a null check extender, something like this</p>
<p>public static bool IsNotNull(this T myObject)<br />
{<br />
       return myObject != null;<br />
}</p>
<p>vs the CouldBeFound method, then you have a not null for everything, and it&#8217;s nice and readable</p>
]]></content:encoded>
	</item>
	<item>
		<title>BUY Adefovir ONLINE WITHOUT PRESCRIPTION</title>
		<link>http://elegantcode.com/2009/04/09/conditional-using/comment-page-1/#comment-45289</link>
		<dc:creator>David Starr</dc:creator>
		<pubDate>Thu, 09 Apr 2009 21:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/04/09/conditional-using/#comment-45289</guid>
		<description>I would rather see an extension method on the userEntry so I could do this:

if(userEntry.IsNotNull())

or something like that.</description>
		<content:encoded><![CDATA[<p>I would rather see an extension method on the userEntry so I could do this:</p>
<p>if(userEntry.IsNotNull())</p>
<p>or something like that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>BUY Adefovir ONLINE WITHOUT PRESCRIPTION</title>
		<link>http://elegantcode.com/2009/04/09/conditional-using/comment-page-1/#comment-45288</link>
		<dc:creator>Chris M</dc:creator>
		<pubDate>Thu, 09 Apr 2009 21:42:31 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/04/09/conditional-using/#comment-45288</guid>
		<description>Bonafide? No.

var userEntry = GetUserEntryFor(userName);
if(userEntry == null)
    return;

using (userEntry)
{
    // Do something with userEntry      
}</description>
		<content:encoded><![CDATA[<p>Bonafide? No.</p>
<p>var userEntry = GetUserEntryFor(userName);<br />
if(userEntry == null)<br />
    return;</p>
<p>using (userEntry)<br />
{<br />
    // Do something with userEntry<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>BUY Adefovir ONLINE WITHOUT PRESCRIPTION</title>
		<link>http://elegantcode.com/2009/04/09/conditional-using/comment-page-1/#comment-45282</link>
		<dc:creator>Bob The Janitor</dc:creator>
		<pubDate>Thu, 09 Apr 2009 20:59:15 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/04/09/conditional-using/#comment-45282</guid>
		<description>Neat yes, 

But why not just do a null check? is there ever a possibility that CouldBeFound is going to do anything more then checking to see if entry is null?

your basically turning one line of code into 3, and kinda makes it harder to read.

Now if you where going to be doing something more then just doing a null check, like doing some form of validation then yes it would be a good coding standard.  In this case I think your over complicating it.   that&#039;s just my 2 cents.</description>
		<content:encoded><![CDATA[<p>Neat yes, </p>
<p>But why not just do a null check? is there ever a possibility that CouldBeFound is going to do anything more then checking to see if entry is null?</p>
<p>your basically turning one line of code into 3, and kinda makes it harder to read.</p>
<p>Now if you where going to be doing something more then just doing a null check, like doing some form of validation then yes it would be a good coding standard.  In this case I think your over complicating it.   that&#8217;s just my 2 cents.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

