<?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: Coding: Keep method/variable names positive</title>
	<atom:link href="http://www.markhneedham.com/blog/2009/06/11/coding-keep-methodvariable-names-positive/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2009/06/11/coding-keep-methodvariable-names-positive/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Sat, 11 Feb 2012 23:17:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Uttam Kini</title>
		<link>http://www.markhneedham.com/blog/2009/06/11/coding-keep-methodvariable-names-positive/comment-page-1/#comment-32505</link>
		<dc:creator>Uttam Kini</dc:creator>
		<pubDate>Thu, 25 Feb 2010 03:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1317#comment-32505</guid>
		<description>Why not have a ValidPolicyNumber() method as well as InValidPolicyNumber, if readability is the concern.

private bool ValidPolicyNumber(string policyNumber) 
{
	string integerPattern = &quot;^[0-9]{7}$&quot;;
	return policyNumber.Substring(0,5) == &quot;POLIC&quot; &amp;&amp; Regex.IsMatch(policyNumber.Substring(6,7), integerPattern)  &amp;&amp; policyNumber.Length == 12
}

private bool InValidPolicyNumber(string policyNumber){

       return !IsValidPolicyNumber(policyNumber);
}</description>
		<content:encoded><![CDATA[<p>Why not have a ValidPolicyNumber() method as well as InValidPolicyNumber, if readability is the concern.</p>
<p>private bool ValidPolicyNumber(string policyNumber)<br />
{<br />
	string integerPattern = &#8220;^[0-9]{7}$&#8221;;<br />
	return policyNumber.Substring(0,5) == &#8220;POLIC&#8221; &amp;&amp; Regex.IsMatch(policyNumber.Substring(6,7), integerPattern)  &amp;&amp; policyNumber.Length == 12<br />
}</p>
<p>private bool InValidPolicyNumber(string policyNumber){</p>
<p>       return !IsValidPolicyNumber(policyNumber);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daily Links for Friday, June 12th, 2009</title>
		<link>http://www.markhneedham.com/blog/2009/06/11/coding-keep-methodvariable-names-positive/comment-page-1/#comment-18542</link>
		<dc:creator>Daily Links for Friday, June 12th, 2009</dc:creator>
		<pubDate>Fri, 12 Jun 2009 11:39:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1317#comment-18542</guid>
		<description>[...] Coding: Keep method/variable names positive at Mark Needham [...]</description>
		<content:encoded><![CDATA[<p>[...] Coding: Keep method/variable names positive at Mark Needham [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Palmer</title>
		<link>http://www.markhneedham.com/blog/2009/06/11/coding-keep-methodvariable-names-positive/comment-page-1/#comment-18540</link>
		<dc:creator>Andy Palmer</dc:creator>
		<pubDate>Fri, 12 Jun 2009 10:38:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1317#comment-18540</guid>
		<description>In this case, I agree with Mark that the InvalidPolicyNumber is hard to grok, and with Zach that the if statement reads better with the original name.
I would implement IsValidPolicyNumber as above, and then have IsInvalidPolicyNumber return !IsValidPolicyNumber.
You get the readability in both client and code then.</description>
		<content:encoded><![CDATA[<p>In this case, I agree with Mark that the InvalidPolicyNumber is hard to grok, and with Zach that the if statement reads better with the original name.<br />
I would implement IsValidPolicyNumber as above, and then have IsInvalidPolicyNumber return !IsValidPolicyNumber.<br />
You get the readability in both client and code then.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/06/11/coding-keep-methodvariable-names-positive/comment-page-1/#comment-18530</link>
		<dc:creator>Mark Needham</dc:creator>
		<pubDate>Fri, 12 Jun 2009 06:46:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1317#comment-18530</guid>
		<description>@Petar Good point I think that would make it even more readable in this case.</description>
		<content:encoded><![CDATA[<p>@Petar Good point I think that would make it even more readable in this case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Petar Petrov</title>
		<link>http://www.markhneedham.com/blog/2009/06/11/coding-keep-methodvariable-names-positive/comment-page-1/#comment-18529</link>
		<dc:creator>Petar Petrov</dc:creator>
		<pubDate>Fri, 12 Jun 2009 06:42:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1317#comment-18529</guid>
		<description>Hi Mark,
I always prefer to prefix my methods that return bool with Is, Has or Can it&#039;s more readable. Take a look at these methods

IsValidPhoneNumber()
IsAccessAllowed()
CanConnectToServer()
HasMultipleComments()

in my opinion they have great names ;)</description>
		<content:encoded><![CDATA[<p>Hi Mark,<br />
I always prefer to prefix my methods that return bool with Is, Has or Can it&#8217;s more readable. Take a look at these methods</p>
<p>IsValidPhoneNumber()<br />
IsAccessAllowed()<br />
CanConnectToServer()<br />
HasMultipleComments()</p>
<p>in my opinion they have great names <img src='http://www.markhneedham.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #366</title>
		<link>http://www.markhneedham.com/blog/2009/06/11/coding-keep-methodvariable-names-positive/comment-page-1/#comment-18495</link>
		<dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #366</dc:creator>
		<pubDate>Thu, 11 Jun 2009 07:21:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1317#comment-18495</guid>
		<description>[...] Coding: Keep method/variable names positive - Mark Needham talks about a few techniques for keeping names of methods and variables easily understandable [...]</description>
		<content:encoded><![CDATA[<p>[...] Coding: Keep method/variable names positive &#8211; Mark Needham talks about a few techniques for keeping names of methods and variables easily understandable [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zach Shaw</title>
		<link>http://www.markhneedham.com/blog/2009/06/11/coding-keep-methodvariable-names-positive/comment-page-1/#comment-18489</link>
		<dc:creator>Zach Shaw</dc:creator>
		<pubDate>Thu, 11 Jun 2009 01:52:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1317#comment-18489</guid>
		<description>Hi Mark,

My 2 cents on this is, I like the method name InvalidPolicyNumber because it&#039;s easier to read in your if statement (I don&#039;t have to pay and attention to the &#039;!&#039;), I don&#039;t disagree that writing a negative can be a little trickier, but I find that &#039;&amp;&amp;&#039; or &#039;&#124;&#124;&#039; bugs are so common it helps to always split them out. For ex:

bool invalid = policyNumberSubstring(0,5) != &quot;POLIC&quot;;
invalid &#124;=  Regex.IsMatch(...) == false;
invalid &#124;=  policyNumber.Length != 12;
return invalid;

I find much easier to read than either of the above</description>
		<content:encoded><![CDATA[<p>Hi Mark,</p>
<p>My 2 cents on this is, I like the method name InvalidPolicyNumber because it&#8217;s easier to read in your if statement (I don&#8217;t have to pay and attention to the &#8216;!&#8217;), I don&#8217;t disagree that writing a negative can be a little trickier, but I find that &#8216;&amp;&amp;&#8217; or &#8216;||&#8217; bugs are so common it helps to always split them out. For ex:</p>
<p>bool invalid = policyNumberSubstring(0,5) != &#8220;POLIC&#8221;;<br />
invalid |=  Regex.IsMatch(&#8230;) == false;<br />
invalid |=  policyNumber.Length != 12;<br />
return invalid;</p>
<p>I find much easier to read than either of the above</p>
]]></content:encoded>
	</item>
</channel>
</rss>

