<?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: How would you refactor this boolean parameter?</title>
	<atom:link href="http://john-sheehan.com/blog/index.php/how-would-you-refactor-this-boolean-parameter/feed/" rel="self" type="application/rss+xml" />
	<link>http://john-sheehan.com/blog/how-would-you-refactor-this-boolean-parameter/</link>
	<description></description>
	<lastBuildDate>Sun, 05 Sep 2010 17:46:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Robz</title>
		<link>http://john-sheehan.com/blog/how-would-you-refactor-this-boolean-parameter/comment-page-1/#comment-14893</link>
		<dc:creator>Robz</dc:creator>
		<pubDate>Fri, 21 Aug 2009 21:09:03 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/how-would-you-refactor-this-boolean-parameter/#comment-14893</guid>
		<description>I might use an enumeration if I were trying to make it very explicit.&lt;br&gt;&lt;br&gt;                    public static PostCollection ListComments(int parentId, int pageNum, int pageSize)&lt;br&gt;                    {&lt;br&gt;                        return PostRepository.List(parentId, pageNum, pageSize, PostCollectionIncludeOptions.IncludeDeleted);&lt;br&gt;&lt;br&gt;                    }&lt;br&gt;&lt;br&gt;                    public enum PostCollectionIncludeOptions { &lt;br&gt;                        IncludeDeleted,&lt;br&gt;                        ExcludeDeleted&lt;br&gt;                    }</description>
		<content:encoded><![CDATA[<p>I might use an enumeration if I were trying to make it very explicit.</p>
<p>                    public static PostCollection ListComments(int parentId, int pageNum, int pageSize)<br />                    {<br />                        return PostRepository.List(parentId, pageNum, pageSize, PostCollectionIncludeOptions.IncludeDeleted);</p>
<p>                    }</p>
<p>                    public enum PostCollectionIncludeOptions { <br />                        IncludeDeleted,<br />                        ExcludeDeleted<br />                    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robz</title>
		<link>http://john-sheehan.com/blog/how-would-you-refactor-this-boolean-parameter/comment-page-1/#comment-14748</link>
		<dc:creator>Robz</dc:creator>
		<pubDate>Fri, 21 Aug 2009 16:09:03 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/how-would-you-refactor-this-boolean-parameter/#comment-14748</guid>
		<description>I might use an enumeration if I were trying to make it very explicit.&lt;br&gt;&lt;br&gt;                    public static PostCollection ListComments(int parentId, int pageNum, int pageSize)&lt;br&gt;                    {&lt;br&gt;                        return PostRepository.List(parentId, pageNum, pageSize, PostCollectionIncludeOptions.IncludeDeleted);&lt;br&gt;&lt;br&gt;                    }&lt;br&gt;&lt;br&gt;                    public enum PostCollectionIncludeOptions { &lt;br&gt;                        IncludeDeleted,&lt;br&gt;                        ExcludeDeleted&lt;br&gt;                    }</description>
		<content:encoded><![CDATA[<p>I might use an enumeration if I were trying to make it very explicit.</p>
<p>                    public static PostCollection ListComments(int parentId, int pageNum, int pageSize)<br />                    {<br />                        return PostRepository.List(parentId, pageNum, pageSize, PostCollectionIncludeOptions.IncludeDeleted);</p>
<p>                    }</p>
<p>                    public enum PostCollectionIncludeOptions { <br />                        IncludeDeleted,<br />                        ExcludeDeleted<br />                    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jaco Pretorius</title>
		<link>http://john-sheehan.com/blog/how-would-you-refactor-this-boolean-parameter/comment-page-1/#comment-14718</link>
		<dc:creator>Jaco Pretorius</dc:creator>
		<pubDate>Wed, 01 Jul 2009 06:34:55 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/how-would-you-refactor-this-boolean-parameter/#comment-14718</guid>
		<description>Didn&#039;t you say you want to actually REMOVE the parameter (not just comment it).  So I assume we can change the PostRepository...&lt;br&gt;&lt;br&gt;In this case I would change the PostRepository.List method to always include deleted items and write an extension method that filters (excludes) deleted posts.&lt;br&gt;&lt;br&gt;This way you should be able to write something like this:&lt;br&gt;&lt;br&gt;return PostRepository.List(parentId, pageNum, pageSize).ExcludeDeleted();&lt;br&gt;&lt;br&gt;or if you want deleted items you just don&#039;t use the filter.</description>
		<content:encoded><![CDATA[<p>Didn&#39;t you say you want to actually REMOVE the parameter (not just comment it).  So I assume we can change the PostRepository&#8230;</p>
<p>In this case I would change the PostRepository.List method to always include deleted items and write an extension method that filters (excludes) deleted posts.</p>
<p>This way you should be able to write something like this:</p>
<p>return PostRepository.List(parentId, pageNum, pageSize).ExcludeDeleted();</p>
<p>or if you want deleted items you just don&#39;t use the filter.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://john-sheehan.com/blog/how-would-you-refactor-this-boolean-parameter/comment-page-1/#comment-14717</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Fri, 26 Jun 2009 12:18:59 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/how-would-you-refactor-this-boolean-parameter/#comment-14717</guid>
		<description>firstly the above code could be improved directly by making the value const.&lt;br&gt;&lt;br&gt;Obviously you wish to avoid having a naked true for readability so you have a few options:&lt;br&gt;&lt;br&gt;public static PostCollection ListComments(int parentId, int pageNum, int pageSize) {&lt;br&gt;    return PostRepository.List(parentId, pageNum, pageSize, true /* includeDeleted */);&lt;br&gt;}&lt;br&gt;&lt;br&gt;I tend to dislike this because /**/ doesn&#039;t nest which can be very painful.&lt;br&gt;The safer way does increase the space consumed at call site, especially on the last parameter&lt;br&gt;&lt;br&gt;public static PostCollection ListComments(int parentId, int pageNum, int pageSize) {&lt;br&gt;    return PostRepository.List(&lt;br&gt;        parentId, pageNum, pageSize, &lt;br&gt;        true -- includeDeleted &lt;br&gt;   );&lt;br&gt;}&lt;br&gt;&lt;br&gt;If you use the parameter in more than one place adding named constants for it can help but is dependent on there being some reasonable place to have the named constants.&lt;br&gt;&lt;br&gt;I am assuming you don&#039;t have access to PostRepository to modify it to include an overload with the default or to add ListActive() and ListAll() or some such?&lt;br&gt;&lt;br&gt;Since named optional parameters are coming to a c# compiler near you in 2010 I wouldn&#039;t suggest doing much with this at all until then though.</description>
		<content:encoded><![CDATA[<p>firstly the above code could be improved directly by making the value const.</p>
<p>Obviously you wish to avoid having a naked true for readability so you have a few options:</p>
<p>public static PostCollection ListComments(int parentId, int pageNum, int pageSize) {<br />    return PostRepository.List(parentId, pageNum, pageSize, true /* includeDeleted */);<br />}</p>
<p>I tend to dislike this because /**/ doesn&#39;t nest which can be very painful.<br />The safer way does increase the space consumed at call site, especially on the last parameter</p>
<p>public static PostCollection ListComments(int parentId, int pageNum, int pageSize) {<br />    return PostRepository.List(<br />        parentId, pageNum, pageSize, <br />        true &#8212; includeDeleted <br />   );<br />}</p>
<p>If you use the parameter in more than one place adding named constants for it can help but is dependent on there being some reasonable place to have the named constants.</p>
<p>I am assuming you don&#39;t have access to PostRepository to modify it to include an overload with the default or to add ListActive() and ListAll() or some such?</p>
<p>Since named optional parameters are coming to a c# compiler near you in 2010 I wouldn&#39;t suggest doing much with this at all until then though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manu Temmerman-Uyttenbroeck</title>
		<link>http://john-sheehan.com/blog/how-would-you-refactor-this-boolean-parameter/comment-page-1/#comment-14715</link>
		<dc:creator>Manu Temmerman-Uyttenbroeck</dc:creator>
		<pubDate>Fri, 26 Jun 2009 06:41:03 +0000</pubDate>
		<guid isPermaLink="false">http://john-sheehan.com/blog/how-would-you-refactor-this-boolean-parameter/#comment-14715</guid>
		<description>Since the method call doesn&#039;t have a lot of parameters, I would use the following:&lt;br&gt;&lt;br&gt;public static PostCollection ListComments(int parentId, int pageNum, int pageSize) {&lt;br&gt;    return PostRepository.List(parentId, pageNum, pageSize, true /* includeDeleted */);&lt;br&gt;}&lt;br&gt;&lt;br&gt;ps: Maybe someone already mentioned it to you, but in chrome your choose-subscription dropdown looks completely black :)</description>
		<content:encoded><![CDATA[<p>Since the method call doesn&#39;t have a lot of parameters, I would use the following:</p>
<p>public static PostCollection ListComments(int parentId, int pageNum, int pageSize) {<br />    return PostRepository.List(parentId, pageNum, pageSize, true /* includeDeleted */);<br />}</p>
<p>ps: Maybe someone already mentioned it to you, but in chrome your choose-subscription dropdown looks completely black :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
