<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Variable Naming on Craig Pardey</title>
    <link>https://www.craigpardey.com/tags/variable-naming/</link>
    <description>Recent content in Variable Naming on Craig Pardey</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Tue, 22 Nov 2011 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.craigpardey.com/tags/variable-naming/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Use affirmative phrases for boolean names</title>
      <link>https://www.craigpardey.com/post/2011-11-22-boolean-naming/</link>
      <pubDate>Tue, 22 Nov 2011 00:00:00 +0000</pubDate>
      <guid>https://www.craigpardey.com/post/2011-11-22-boolean-naming/</guid>
      <description>&lt;p&gt;Please use affirmative phrases when naming your boolean variables and flags -&#xA;I find that it makes code much more readable.  This is particularly true when&#xA;naming the configuration settings used to turn features on or off.  If the&#xA;setting is named in the negative then I have to use a double negative to&#xA;enable it, and everyone learnt in high school that double negatives are a Bad&#xA;Thing.&lt;/p&gt;&#xA;&lt;p&gt;For example, if I have a feature that sends emails and I want to make this&#xA;behaviour conditional then an appropriate variable name would be &amp;ldquo;boolean&#xA;sendEmail = true&amp;rdquo;.  It&amp;rsquo;s easily comprehended.  Contrast that with the same&#xA;feature phrased negatively: &amp;ldquo;boolean disableEmail = false&amp;rdquo;.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
