<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Improving Software</title>
	<atom:link href="http://improvingsoftware.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://improvingsoftware.com</link>
	<description>Upgrading the software development process one reader at a time.</description>
	<lastBuildDate>Mon, 30 Jan 2012 15:39:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='improvingsoftware.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/149bfdb29ba904c2f5cc2a3c8487e642?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Improving Software</title>
		<link>http://improvingsoftware.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://improvingsoftware.com/osd.xml" title="Improving Software" />
	<atom:link rel='hub' href='http://improvingsoftware.com/?pushpress=hub'/>
		<item>
		<title>5 Best Practices for Commenting Your Code</title>
		<link>http://improvingsoftware.com/2011/06/27/5-best-practices-for-commenting-your-code/</link>
		<comments>http://improvingsoftware.com/2011/06/27/5-best-practices-for-commenting-your-code/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 23:25:09 +0000</pubDate>
		<dc:creator>johnfx</dc:creator>
				<category><![CDATA[How To...]]></category>
		<category><![CDATA[Technology Tips]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[Commenting Code]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://improvingsoftware.com/?p=2492</guid>
		<description><![CDATA[One of the first things you learn to do incorrectly as a programmer is commenting your code. My experience with student and recently graduated programmers tells me that college is a really good place to learn really bad code commenting techniques. This is just one of those areas where in-theory and in-practice don&#8217;t align well. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2492&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the first things you learn to do incorrectly as a programmer is commenting your code. My experience with student and recently graduated programmers tells me that college is a really good place to learn really bad code commenting techniques. This is just one of those areas where in-theory and in-practice don&#8217;t align well.</p>
<p>There are two factors working against you learning good commenting technique in college.</p>
<ol>
<li> Unlike the real world, you do a lot of small one-off projects as a solo developer.  There&#8217;s no one out there fantasizing about dropping a boulder on you for making them decipher your coding atrocity.</li>
<li> That commenting style you are emulating from your textbook is only a good practice when the comments are intended for a student learning to program. It is downright annoying to professional programmers.</li>
</ol>
<p>These tips are primarily intended for upstart programmers who are transitioning into the real world of programming, and hopefully will prevent a few from looking quite so n00bish during their first code review. Code Review? Oh yeah, that&#8217;s something else they didn&#8217;t teach you in school, but that&#8217;s a whole other article, I&#8217;ll defer to <a title="Free Book: Best Kept Secrets of Peer Code Review " href="http://smartbear.com/best-kept-secrets-of-peer-code-review/" target="_blank">Jason Cohen</a> on that one.</p>
<p>So let&#8217;s get started&#8230;</p>
<h2>(1) Comments are not subtitles</h2>
<p>It&#8217;s easy to project your own worldview that code is a foreign language understood only by computers, and that you are doing the reader a service by explaining what each line does in some form of human language. Or perhaps you are doing it for the benefit of that non-programmer manager who will certainly want to read your code (Spoiler: He won&#8217;t).</p>
<p>Look, in the not too distant future, you will be able to read code almost as easily as your native language, and everyone else who will even glance at it almost certainly already can. By then you will realize how silly it is to write comments like these:</p>
<p><pre class="brush: csharp; light: true;">
// Loop through all bananas in the bunch
foreach(banana b in bunch) {
    monkey.eat(b);  //make the monkey eat one banana
}
</pre></p>
<p>You may have been taught to program by first writing  pseudo-code comments then writing the real code into that wire-frame. This is a perfectly reasonable approach for a novice programmer. Just be sure to <strong>replace the comments with the code</strong>, and don&#8217;t leave them in there.</p>
<blockquote><p><strong>Computer:</strong> Enemy is matching velocity.<br />
<strong>Gwen DeMarco:</strong> The enemy is matching velocity!<br />
<strong>Sir Alexander Dane:</strong> We heard it the first time!<br />
<strong>Gwen DeMarco:</strong> Gosh, I&#8217;m doing it. I&#8217;m repeating the darn computer!</p>
<p style="text-align:right;"><a title="Souce: Galaxy Quest (IMDB)" href="http://www.imdb.com/title/tt0177789/" target="_blank">-Galaxy Quest</a></p>
</blockquote>
<p><strong>Exceptions:</strong></p>
<ul>
<li>Code examples used to teach a concept or new programming language.</li>
<li>Programming languages that aren&#8217;t remotely human readable (Assembly, Perl)</li>
</ul>
<h2>(2) Comments are not an art project</h2>
<p>This is a bad habit propagated by code samples in programing books and open source copyright notices that are desperate to make you pay attention to them.</p>
<p><pre class="brush: csharp; gutter: true; toolbar: true; wrap-lines: false;">
/*
   _     _      _     _      _     _      _     _      _     _      _     _
  (c).-.(c)    (c).-.(c)    (c).-.(c)    (c).-.(c)    (c).-.(c)    (c).-.(c)
   / ._. \      / ._. \      / ._. \      / ._. \      / ._. \      / ._. \
 __\( Y )/__  __\( Y )/__  __\( Y )/__  __\( Y )/__  __\( Y )/__  __\( Y )/__
(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)
   || M ||      || O ||      || N ||      || K ||      || E ||      || Y ||
 _.' `-' '._  _.' `-' '._  _.' `-' '._  _.' `-' '._  _.' `-' '._  _.' `-' '._
(.-./`-'\.-.)(.-./`-'\.-.)(.-./`-'\.-.)(.-./`-'\.-.)(.-./`-'\.-.)(.-./`-'\.-.)
 `-'     `-'  `-'     `-'  `-'     `-'  `-'     `-'  `-'     `-'  `-'     `-'

                 -It's Monkey Business Time! (Version 1.5)
*/
</pre></p>
<p>Why, that&#8217;s silly. You&#8217;d never do something so silly in your comments.</p>
<p>ORLY? Does this look familiar?</p>
<p><pre class="brush: csharp; toolbar: false; wrap-lines: true;">
   +------------------------------------------------------------+
   | Module Name: classMonkey                                   |
   | Module Purpose: emulate a monkey                           |
   | Inputs: Bananas                                              |
   | Outputs: Grunts                                            |
   | Throws: Poop                                               |
   +------------------------------------------------------------+
</pre></p>
<p>Programmers love to go &#8220;touch up&#8221; their code to make it look good when their brain hurts and they want something easy to do for a while. It may be a waste of time, but at least they are wasting it during periods where they wouldn&#8217;t be productive anyway.</p>
<p>The trouble is that it creates a time-wasting maintenance tax imposed on anyone working with the code in the future just to keep the pretty little box intact when the text ruins the symmetry of it. Even programmers who hate these header blocks tend to take the time to maintain them because they like consistency and every other method in the project has one.</p>
<blockquote><p>How much is it bugging you that the right border on that block is misaligned? Yeah. That&#8217;s the point.</p></blockquote>
<h2>(3) Header Blocks: Nuisance or Menace?</h2>
<p>This one is going to be controversial, but I&#8217;m holding my ground. I don&#8217;t like blocks of header comments at the top of every file, method or class.</p>
<p>Not in a boat, not with a goat.<br />
Why? Well let me tell you, George McFly&#8230;</p>
<p><strong>They are enablers for badly named objects/methods</strong> &#8211; Of course, header blocks aren&#8217;t the <strong>cause</strong> for badly named identifiers, but they are an easy excuse to not  put in the work to come up with meaningful names, an often deceptively difficult task. It provides too much slack to just assume the consumer can just read the &#8220;inline documentation&#8221; to solve the mystery of what the <strong>DoTheMonkeyThing</strong> method is all about.</p>
<blockquote><p><strong>JohnFx&#8217;s Commandment:</strong><br />
The consumer of thy code should never have to see its source code to use it, not even the comments.</p></blockquote>
<p><strong>They never get updated:</strong> We all know that methods are supposed to remain short and sweet, but real life gets in the way and before you know it you have a 4K line class and the header block is scrolled off of the screen in the IDE 83% of the time. Out of sight, out of mind, never updated.</p>
<p>The bad news is that they are usually out of date. The good news is that people rarely read them so the opportunity for confusion is mitigated somewhat. Either way, why waste your time on something that is more likely to hurt than help?</p>
<blockquote><p><strong>JohnFx&#8217;s Maxim of Plagiarized Ideas :</strong><br />
Bad Documentation is worse than no documentation.</p></blockquote>
<p><strong>Exception:</strong> Some languages (<a title="How to Write Doc Comments for the Javadoc Tool" href="http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html">Java</a>/<a title="On Writing Good XML Documentation Comments" href="http://www.paraesthesia.com/archive/2007/11/14/on-writing-good-xml-documentation-comments.aspx">C#</a>) have tools that can digest specially formatted header block comments into documentation or Intellisense/Autocomplete hints. Still, remember rule (2) and stick to the minimum required by the tool and draw the line at creating any form of <a title="Text Ascii Art Generator" href="http://patorjk.com/software/taag/" target="_blank">ASCII art</a>.</p>
<h2>(4) Comments are not source control</h2>
<p>This issue is so common that I have to assume that programmers (a) don&#8217;t know how to use source control; or  (b) don&#8217;t trust it.</p>
<p><strong>Archetype 1: &#8220;The Historian&#8221;<br />
</strong></p>
<p><pre class="brush: csharp; toolbar: false; wrap-lines: true;">
     // method name: pityTheFoo (included for the sake of redundancy)
     // created: Feb 18, 2009 11:33PM
     // Author: Bob
     // Revisions: Sue (2/19/2009) - Lengthened monkey's arms
     //            Bob (2/20/2009) - Solved drooling issue

     void pityTheFoo() {
          ...
     }
</pre></p>
<p>The programmers involved in the evolution of this method probably checked this code into a source control system designed to track the change history of every file, but decided to clutter up the code anyway. These same programmers more than likely always leave the <strong>Check-In Comments</strong> box empty on their commits.</p>
<p>I think I hate this type of comment worst of all, because it imposes a duty on other programmers to keep up the tradition of duplicating effort and wasting time maintaining this chaff. I almost always delete this mess from any code I touch without an ounce of guilt. I encourage you to do the same.</p>
<p><strong>Archetype 2: &#8220;The Code Hoarder&#8221;<br />
</strong></p>
<p><pre class="brush: csharp; toolbar: false; wrap-lines: true;">

     void monkeyShines() {
          if (monkeysOnBed(Jumping).count &gt; max) {
             monkeysOnBed.breakHead();

             // code removed, smoothie shop closed.
             // leaving it in case a new one opens.
             // monkeysOnBed.Drink(BananaSmoothie);
          }
     }
</pre></p>
<p>Another feature of any tool that has any right to call itself a SCM is the ability to recover old versions of code, including the parts you removed. If you want to be triple super extra sure, create a <a title="Source Control Concepts: Branches" href="http://www.ericsink.com/scm/scm_branches.html" target="_blank">branch </a>to help you with your trust <a title="Hoarders - A&amp;E TV" href="http://www.aetv.com/hoarders/" target="_blank">issues</a>.</p>
<h2>(5) Comments are a code smell</h2>
<p>Comments are little signposts in your code explaining it to future archaeologists that desperately need to understand how 21st century man sorted lists of purchase orders.</p>
<p>Unfortunately, as Donald Norman explained so brilliantly in <a title="The Design of Everyday Things (Donald Norman)" href="http://www.amazon.com/gp/product/0465067107/ref=as_li_ss_il?ie=UTF8&amp;tag=sofblo0e-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399369&amp;creativeASIN=0465067107">The Design of Everyday Things</a>, things generally need signs because their <a title="Affordances and Design" href="http://www.jnd.org/dn.mss/affordances_and_design.html" target="_blank">affordances </a>have failed. In plain English, when you add a comment you are admitting that you have written code that doesn&#8217;t communicate its purpose well.</p>
<div id="attachment_2556" class="wp-caption aligncenter" style="width: 310px"><a href="http://softwareplusplus.files.wordpress.com/2011/06/mopsnk1.gif"><img class="size-medium wp-image-2556 " title="MopSink" src="http://softwareplusplus.files.wordpress.com/2011/06/mopsnk1.gif?w=300&#038;h=215" alt="" width="300" height="215" /></a><p class="wp-caption-text">Sign:&quot;This is a mop sink.&quot; Why would that be necces... oh.</p></div>
<p>Despite what your prof told you in college, a high comment to code ratio is not a good thing.  I&#8217;m not saying to avoid them completely, but if you have a 1-1 or even a 5-1 ratio of LOC to comments, you are probably overdoing it. The need for excessive comments is a good indicator that your code needs <a title="Refactoring (Martin Fowler)" href="http://www.refactoring.com/sources.html" target="_blank">refactoring</a>.</p>
<blockquote><p>Whenever you think, &#8220;This code needs a comment&#8221; follow that thought with, &#8220;How could I modify the code so its purpose is obvious?&#8221;<br />
Talk with your code, not your comments.</p></blockquote>
<p><strong>Technique 1</strong>: Use meaningful identifiers and constants (even if they are single use)</p>
<p><pre class="brush: csharp; toolbar: false; wrap-lines: true;">
     // Before
     // Calculate monkey's arm length
     // using it's height and the magic monkey arm ratio
     double length = h * 1.845; //magic numbers are EVIL!

    // After - No comment required
    double armLength = height * MONKEY_ARM_HEIGHT_RATIO;
</pre></p>
<p><strong>Technique 2:</strong> Use strongly typed input and output parameters</p>
<p><pre class="brush: csharp; toolbar: false; wrap-lines: true;">
      // Before
      // input parameter monkeysToFeed:
      // DataSet with one table containing two columns
      //     MonkeyID (int) the monkey to feed
      //     MonkeyDiet (string) that monkey's diet
      void feedMonkeys(DataSet monkeysToFeed) {
      }

     //  After: No comment required
     void feedMonkeys(Monkeys monkeysToFeed) {
     }
</pre></p>
<p><strong>Technique 3:</strong> Extract commented blocks into another method</p>
<p><pre class="brush: csharp; toolbar: false; wrap-lines: true;">
      // Before

      // Begin: flip the &quot;hairy&quot; bit on monkeys
      foreach(monkey m in theseMonkeys) {
          // 5-6 steps to flip bit.
      }
      // End: flip the &quot;hairy&quot; bit on monkeys

     // After No comment required
     flipHairyBit(theseMonkeys);
</pre></p>
<p>As an added bonus, technique 3 will tend to reduce the size of your methods and minimizing the nesting depth (<a title="Coding Horror: Flattening Arrow Code" href="http://www.codinghorror.com/blog/2006/01/flattening-arrow-code.html">see also &#8220;Flattening Arrow Code&#8221;</a>) all of which contribute to eliminating the need for commenting the closing tags of blocks like this:</p>
<p><pre class="brush: csharp; toolbar: false; wrap-lines: true;">
            } // ... if see evil
         } // ... while monkey do.
      } // ... if monkey see.
    } // ... class monkey
  } // ... namespace primate
</pre></p>
<h2>Acknowledgments</h2>
<p>Several of the ideas presented here, and a good deal of the fundamental things I know about programming as part of a team, and not as a lone-wolf working on a college project I learned from the book <a title="Code Complete: A Practical Handbook of Software Construction" href="http://www.amazon.com/gp/product/0735619670/ref=as_li_ss_tl?ie=UTF8&amp;tag=sofblo0e-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399369&amp;creativeASIN=0735619670" target="_blank">Code Complete</a> by Steve McConnell. If you are a working programmer and have not read this book year, stop what you are doing and read it before you write another line of code.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/softwareplusplus.wordpress.com/2492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/softwareplusplus.wordpress.com/2492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/softwareplusplus.wordpress.com/2492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/softwareplusplus.wordpress.com/2492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/softwareplusplus.wordpress.com/2492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/softwareplusplus.wordpress.com/2492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/softwareplusplus.wordpress.com/2492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/softwareplusplus.wordpress.com/2492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/softwareplusplus.wordpress.com/2492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/softwareplusplus.wordpress.com/2492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/softwareplusplus.wordpress.com/2492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/softwareplusplus.wordpress.com/2492/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/softwareplusplus.wordpress.com/2492/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/softwareplusplus.wordpress.com/2492/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2492&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://improvingsoftware.com/2011/06/27/5-best-practices-for-commenting-your-code/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccddf43f6a7a99378f32a0c39c3f8733?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">JohnFx</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2011/06/mopsnk1.gif?w=300" medium="image">
			<media:title type="html">MopSink</media:title>
		</media:content>
	</item>
		<item>
		<title>Quick Tip: Comparing a .NET string to multiple values</title>
		<link>http://improvingsoftware.com/2011/06/16/quick-tip-comparing-a-net-string-to-multiple-values/</link>
		<comments>http://improvingsoftware.com/2011/06/16/quick-tip-comparing-a-net-string-to-multiple-values/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 16:00:53 +0000</pubDate>
		<dc:creator>johnfx</dc:creator>
				<category><![CDATA[Useful Code Snippets]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Extenders]]></category>
		<category><![CDATA[Strings]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://improvingsoftware.com/?p=2428</guid>
		<description><![CDATA[The Problem Do you ever wish you could use the SQL IN operator in your C# code to make your conditional blocks more concise and your code easier to read? Perhaps it&#8217;s just my persnickety nature, but I believe that line-wrapped conditional expressions like this are a code smell. This would be so much cleaner&#8230; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2428&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>The Problem</h2>
<p>Do you ever wish you could use the<a title="W3 Schools: SQL IN Operator Reference" href="http://www.w3schools.com/sql/sql_in.asp" target="_blank"> SQL IN operator</a> in your C# code to make your conditional blocks more concise and your code easier to read?</p>
<p>Perhaps it&#8217;s just my persnickety nature, but I believe that line-wrapped conditional expressions like this are a code smell.</p>
<p><pre class="brush: csharp; gutter: true; toolbar: true; wrap-lines: false;">
if (animal.Equals(&quot;Cow&quot;) ||
   animal.Equals(&quot;Horse&quot;) ||
   animal.Equals(&quot;Hen&quot;))
{
   Console.WriteLine(&quot;We must be on the farm.&quot;);
}
</pre></p>
<p>This would be so much cleaner&#8230;</p>
<p><pre class="brush: csharp; gutter: true; toolbar: true; wrap-lines: false;">
if (animal.CompareMultiple(&quot;Cow&quot;,&quot;Horse&quot;,&quot;Hen&quot;)
{
   Console.WriteLine(&quot;We must be on the farm.&quot;);
}
</pre></p>
<h2>The Code</h2>
<p>With a simple extension class you can upgrade your string classes to do this very thing.</p>
<p><strong>Step 1:</strong> Create an extension class as demonstrated here.</p>
<p><strong>C#</strong></p>
<p><pre class="brush: csharp; gutter: true; toolbar: true; wrap-lines: false;">
namespace extenders.strings
{
  public static class StringExtender {

    public static bool CompareMultiple(this string data, StringComparison compareType, params string[] compareValues) {
      foreach (string s in compareValues) {
        if (data.Equals(s, compareType)) {
          return true;
        }
      }
      return false;
   }
  }
}
</pre></p>
<p><strong>VB.NET</strong></p>
<p><pre class="brush: vb; gutter: true; toolbar: true; wrap-lines: false;">
Imports System.Runtime.CompilerServices

Namespace Extenders.Strings

  Public Module StringExtender

    &lt;Extension()&gt; _
    Public Function CompareMultiple(ByVal this As String, compareType As StringComparison, ParamArray compareValues As String()) As Boolean

       Dim s As String

       For Each s In compareValues
         If (this.Equals(s, compareType)) Then
            Return True
         End If
       Next s

       Return False
    End Function

  End Module

End Namespace
</pre></p>
<p><strong>Step 2:</strong> Add a reference to the extension namespace and use it.</p>
<p><strong>C#</strong></p>
<p><pre class="brush: csharp; gutter: true; toolbar: true; wrap-lines: false;">
using extenders.strings;

namespace MyProgram
{
  static class program {
    static void Main() {

      string foodItem = &quot;Bacon&quot;;

      if (foodItem.CompareMultiple(StringComparison.CurrentCultureIgnoreCase, &quot;bacon&quot;, &quot;eggs&quot;, &quot;biscuit&quot;)) {
         System.Console.WriteLine(&quot;Breakfast!&quot;);
      }
      else {
         System.Console.Write(&quot;Dinner&quot;);
      }

    }
  }
}
</pre></p>
<p><strong>VB.NET</strong></p>
<p><pre class="brush: csharp; gutter: true; toolbar: true; wrap-lines: false;">
Imports StringExtenderExampleVB.Extenders.Strings

Module Program

  Sub Main()
    Dim foodItem As String = &quot;Bacon&quot;

    If (foodItem.CompareMultiple(System.StringComparison.CurrentCultureIgnoreCase, &quot;bacon&quot;, &quot;eggs&quot;, &quot;biscuit&quot;)) Then
      System.Console.WriteLine(&quot;Breakfast!&quot;)
    Else
      System.Console.Write(&quot;Dinner&quot;)
    End If

    System.Console.ReadLine()
  End Sub

End Module
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/softwareplusplus.wordpress.com/2428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/softwareplusplus.wordpress.com/2428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/softwareplusplus.wordpress.com/2428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/softwareplusplus.wordpress.com/2428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/softwareplusplus.wordpress.com/2428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/softwareplusplus.wordpress.com/2428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/softwareplusplus.wordpress.com/2428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/softwareplusplus.wordpress.com/2428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/softwareplusplus.wordpress.com/2428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/softwareplusplus.wordpress.com/2428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/softwareplusplus.wordpress.com/2428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/softwareplusplus.wordpress.com/2428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/softwareplusplus.wordpress.com/2428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/softwareplusplus.wordpress.com/2428/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2428&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://improvingsoftware.com/2011/06/16/quick-tip-comparing-a-net-string-to-multiple-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccddf43f6a7a99378f32a0c39c3f8733?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">JohnFx</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding combo-box style dropdowns to your web page</title>
		<link>http://improvingsoftware.com/2011/04/21/adding-combo-box-style-dropdowns-to-your-web-page/</link>
		<comments>http://improvingsoftware.com/2011/04/21/adding-combo-box-style-dropdowns-to-your-web-page/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 00:48:06 +0000</pubDate>
		<dc:creator>johnfx</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://improvingsoftware.com/?p=2297</guid>
		<description><![CDATA[Announcing the Improved Dropdown jQuery plugin! I&#8217;m happy to announce that I&#8217;ve released a new jQuery plugin today that will enable web page authors to create a richer user experience than is offered by the standard implementation of the SELECT element in poplar browser platforms. The plugin will supercharge the dropdown controls into combo-box style [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2297&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Announcing the Improved Dropdown jQuery plugin!</h2>
<p>I&#8217;m happy to announce that I&#8217;ve released a new jQuery plugin today that will enable web page authors to create a richer user experience than is offered by the standard implementation of the <span style="color:#0000ff;">SELECT</span> element in poplar browser platforms. The plugin will supercharge the dropdown controls into combo-box style controls that allow filtering the selection list based on keyboard input.</p>
<p>The following two screen shots tell the story of this plugin better than a 100 words ever could.</p>
<div id="attachment_2306" class="wp-caption aligncenter" style="width: 381px"><a href="http://softwareplusplus.files.wordpress.com/2011/04/beforefilter.png"><img class="size-full wp-image-2306" title="An Improved Dropdown demonstrating groups and disabling items" src="http://softwareplusplus.files.wordpress.com/2011/04/beforefilter.png?w=468" alt="An Improved Dropdown demonstrating groups and disabling items"   /></a><p class="wp-caption-text">Headings and disabled items are fully supported.</p></div>
<div id="attachment_2307" class="wp-caption aligncenter" style="width: 404px"><a href="http://softwareplusplus.files.wordpress.com/2011/04/afterfilter.png"><img class="size-full wp-image-2307" title="Filtering down to the potential matches based on keyboard input." src="http://softwareplusplus.files.wordpress.com/2011/04/afterfilter.png?w=468" alt="Filtering down to the potential matches based on keyboard input."   /></a><p class="wp-caption-text">This list is filtered to only matching items as the user types.</p></div>
<h2>Another auto-complete plugin? Why?</h2>
<p>Okay. I am fully aware that there exist a number of freely available jQuery plugins with similar functionality. However, none of them seemed to fit exactly what I needed on one of my development projects so I built ImprovedDropDown originally for my own use, and later decided it was worth sharing with the developer community.</p>
<p><strong>Key differences between ImprovedDropdown and the typical auto-complete plugin:</strong></p>
<ol>
<li>It allows free-text entry to filter the list, but forces the user to pick an item that is in the list.</li>
<li>When filtering/suggesting items it uses <em>open-ended contains logic</em>, not <em>begins-with</em> logic.</li>
<li>It pulls the suggestion list from plain-old client side HTML rather than requiring an AJAX call for suggestions.</li>
<li>It supports non-selectable group headers in the list similar to an <span style="color:#0000ff;">OPTGROUP</span> tag in a <span style="color:#0000ff;">SELECT</span> control.</li>
</ol>
<p>Item #3 at first glance may look like a step back since AJAX is a cool way to serve up suggestions for a long list of choices. However, I was looking for a super simple way to add functionality to a dropdown without adding the additional complexity of  extra server-side code.</p>
<p>For small to medium sized lists it seemed overkill to implement AJAX handlers on the server all the time. As a bonus, this control will work just fine for static web-sites where the hosting provider doesn&#8217;t make available a server-side scripting capabilities.</p>
<h2>Do I have to pay for it?</h2>
<p>Nope. I&#8217;m releasing this project as <strong>open-source freeware</strong> as a thank you to all the other developers that have contributed greatly to many of my development projects by  contributing their own code to the community. I&#8217;ve licensed it under the<a title="Apache 2.0 License" href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank"> Apache 2.0 License</a>, which is fairly liberal in terms of what you can do with the code either in commercial or non-commercial software.</p>
<p>Although it isn&#8217;t mandated by the license, the one thing I ask in return for using the software is to let me know that you are using it. A shout-out on twitter (<a title="JohnFx on twitter" href="http://twitter.com/#!/johnfx" target="_blank">@JohnFx</a>), an e-mail, blog post, or comment somewhere on this blog will suffice.  You don&#8217;t have to tell me any specifics of your project, unless you just want to brag on it. Primarily, I am just using this request as a way to gauge how much use it is actually getting in the wild.</p>
<h2>Is it complicated to use?</h2>
<p>If you are new to <a title="jQuery - write less. do more." href="http://www.jQuery.org" target="_blank">jQuery</a>, there is a small learning curve there, but even if you don&#8217;t know jQuery you can pretty much just copy the included examples to get up and running.</p>
<p><strong>Step 1:</strong> Copy the files to your site (jQuery + the 3 ImprovedDropdown files)</p>
<p><strong>Step 2:</strong> Add a few references to the <span style="color:#0000ff;">HEAD</span> section of the page where you want the control.</p>
<p><strong>Step 3:</strong> In the $(document).ready event, call the improveDropdown method to upgrade one or more controls on that page.</p>
<p>Example code (steps 2-3) to upgrade all <span style="color:#0000ff;">SELECT</span> elements on the  page to Improved Dropdowns:</p>
<p><pre class="brush: jscript; wrap-lines: false;">

&lt;head&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;js/improvedDropDown.js&quot;&gt;&lt;/script&gt;
&lt;link rel=&quot;StyleSheet&quot; href=&quot;css/improvedDropdown.css&quot; type=&quot;text/css&quot; /&gt;

    &lt;script type=&quot;text/javascript&quot;&gt;
       $(document).ready(function () {
            $(&quot;select&quot;).improveDropDown();
       });
    &lt;/script&gt;

&lt;/head&gt;

</pre></p>
<h2>Sounds Great. Where can I get it?</h2>
<p>You can download all the files you need to get started from the <a title="Improved Dropdown jQuery Plugin @ jQuery.org" href="http://plugins.jquery.com/project/ImprovedDropdown" target="_blank">Improved Dropdown page in the jQuery plugin library</a>.</p>
<p>The project is also hosted on the <a title="Improved Dropdown jQuery Control @ BitBucket.org" href="https://bitbucket.org/Johnfx/improveddropdown-jquery-plugin/downloads" target="_blank">Improved Dropdown project page at BitBucket</a> (Go Mercurial!) in case you&#8217;d like to contribute, follow the project, or just laugh at all the bug-fix changesets that it took to get to the 1.x version.</p>
<h2>What do you think?</h2>
<p>I put considerable thought into making  the integration of this functionality into existing web pages super quick and easy. I hope that you will find it easy to work with and your users will like the functionality it offers. If you have any comments, complaints, or suggestions for improvement I would love to hear them. Just post a comment somewhere on the blog or drop me an e-mail (see &#8220;About&#8221; tab for my address).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/softwareplusplus.wordpress.com/2297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/softwareplusplus.wordpress.com/2297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/softwareplusplus.wordpress.com/2297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/softwareplusplus.wordpress.com/2297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/softwareplusplus.wordpress.com/2297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/softwareplusplus.wordpress.com/2297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/softwareplusplus.wordpress.com/2297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/softwareplusplus.wordpress.com/2297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/softwareplusplus.wordpress.com/2297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/softwareplusplus.wordpress.com/2297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/softwareplusplus.wordpress.com/2297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/softwareplusplus.wordpress.com/2297/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/softwareplusplus.wordpress.com/2297/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/softwareplusplus.wordpress.com/2297/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2297&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://improvingsoftware.com/2011/04/21/adding-combo-box-style-dropdowns-to-your-web-page/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccddf43f6a7a99378f32a0c39c3f8733?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">JohnFx</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2011/04/beforefilter.png" medium="image">
			<media:title type="html">An Improved Dropdown demonstrating groups and disabling items</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2011/04/afterfilter.png" medium="image">
			<media:title type="html">Filtering down to the potential matches based on keyboard input.</media:title>
		</media:content>
	</item>
		<item>
		<title>Replacing multiple spaces in a string with a single space in SQL</title>
		<link>http://improvingsoftware.com/2011/03/21/replacing-multiple-spaces-in-a-string-with-a-single-space-in-sql/</link>
		<comments>http://improvingsoftware.com/2011/03/21/replacing-multiple-spaces-in-a-string-with-a-single-space-in-sql/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 19:46:47 +0000</pubDate>
		<dc:creator>johnfx</dc:creator>
				<category><![CDATA[How To...]]></category>
		<category><![CDATA[Technology Tips]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Strings]]></category>
		<category><![CDATA[tSQL]]></category>

		<guid isPermaLink="false">http://improvingsoftware.com/?p=2214</guid>
		<description><![CDATA[After reading Jeff Moden&#8217;s article &#8220;Replace Multiple Spaces with One&#8221; describing an approach to collapse white space in a string, I was troubled by the need for a temporary placeholder. I&#8217;m generally skeptical of any solution that requires picking a character that doesn&#8217;t naturally occur in the data. It just feels like you are building [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2214&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After reading Jeff Moden&#8217;s article <a title="REPLACE Multiple Spaces with One (Jeff Moden)" href="http://www.sqlservercentral.com/articles/T-SQL/68378/" target="_blank">&#8220;Replace Multiple Spaces with One&#8221;</a> describing an approach to collapse white space in a string, I was troubled by the need for a temporary placeholder. I&#8217;m generally skeptical of any solution that requires picking a character that doesn&#8217;t naturally occur in the data. It just feels like you are building a time-bomb into the app even if you are very careful to pick something so zany it has a very little chance of showing up and causing problems. Also, the character you pick depends on the data you are running this against, so it might not make for a great generic solution.</p>
<p>So today&#8217;s project was to find another way to skin that cat without  inserting bogus characters into the data.</p>
<h2>Statement of The Problem</h2>
<p>For those who haven&#8217;t read Jeff&#8217;s article, here is a basic statement of the task:</p>
<blockquote><p>Replace any continuous series of repeating spaces of in a database column with a single space.</p></blockquote>
<p><strong>Constraints:</strong></p>
<ol>
<li>Although a <a title="Regular Expressions Make Pattern Matching And Data Extraction Easier" href="http://msdn.microsoft.com/en-us/magazine/cc163473.aspx" target="_blank">CLR UDF using .NET&#8217;s regular expression library</a> is the most straightforward way to do this, the original article went for a pure SQL approach so I did the same.</li>
<li>My solution is based language features available in MS SQL Server 2005 and later.</li>
</ol>
<h2>Test Data</h2>
<p>I used a permanent table to test this instead of a temporary table, but used the same sample data set from Jeff&#8217;s article.  Also, I inserted these same rows 100K times so I had a large enough data set to be useful for performance testing.</p>
<p><pre class="brush: sql; gutter: false; toolbar: true; wrap-lines: false;">

CREATE TABLE SpacesTest(
ID int IDENTITY(1,1) NOT NULL,
SomeText varchar(max) NULL,
)

go
DECLARE @loopCounter int
set @test=0

WHILE (@loopCounter&lt;100000)
BEGIN
  INSERT INTO spacestest (sometext)
    SELECT '  This      has multiple   unknown                 spaces in        it.   '
    UNION ALL SELECT 'So                     does                      this!'
    UNION ALL SELECT 'As                                does                        this'
    UNION ALL SELECT 'This, that, and the other  thing.'
    UNION ALL SELECT 'This needs no repair.'
END

</pre></p>
<h2>Solutions</h2>
<p>If we could assume that no series of spaces in the string consisted of more than two spaces, this challenge could be met with a simple application of the <span style="color:#3366ff;">REPLACE </span>statement to replace all double spaces with single spaces. However, given series of arbitrary length you need would need to repeat this operation until you had collapsed the longer series down to single spaces.</p>
<p><strong>You could do it iteratively like this:</strong></p>
<p><pre class="brush: sql; gutter: false; toolbar: true; wrap-lines: false;">
WHILE EXISTS(SELECT * FROM SpacesTest WHERE (SomeText like '%  %'))
BEGIN
 UPDATE SpacesTest
 SET SomeText=REPLACE(SomeText,'  ',' ')
 WHERE (SomeText like '%  %')
END
</pre></p>
<p>While the iterative approach works just fine, it does do of repetitive updates to each row and requires you to write the intermediate output to a temporary table if you just want to query the data rather than updating the source table.  I came up with the following recursive solution that doesn&#8217;t require the intermediate updates and is more of  &#8220;set based&#8221; approach.</p>
<p><strong>Recursive Solution:</strong></p>
<p><pre class="brush: sql; gutter: false; toolbar: true; wrap-lines: false;">
WITH spacesCollapsed (ID,SomeText) AS
(
   SELECT ID, cast(LTRIM(RTRIM(SomeText)) as varchar(max)) FROM SpacesTest
   UNION ALL
   SELECT ID, cast(REPLACE(SomeText,'  ',' ') as varchar(max)) as SomeText FROM spacesCollapsed WHERE (SomeText like '%  %')
)
SELECT ID, SomeText
FROM (
   SELECT ID,SomeText,  ROW_NUMBER() OVER(PARTITION BY ID ORDER BY min(len(sometext))) as GroupRowNum
   FROM spacesCollapsed
   GROUP BY ID,SomeText
 ) as reductions
WHERE reductions.GroupRowNum=1;
</pre></p>
<h2>Conclusions</h2>
<p>My new recursive approach did generate valid output and does solve the dilemma of choosing a character that won&#8217;t occur in the data. The bad news is that it didn&#8217;t perform all that well. In fact, it was over 26x slower than Jeff&#8217;s approach. The iterative approach performed a lot better, but was still almost 6x slower than the benchmark. I suspect the performance problems with both of my alternatives come from the need to make multiple passes at the source data using a non-SARGable expression in the where clause.</p>
<div id="attachment_2275" class="wp-caption aligncenter" style="width: 478px"><a href="http://softwareplusplus.files.wordpress.com/2011/03/jeff_stats.png"><img class="size-full wp-image-2275 " title="Query Stats for Jeff's Approach" src="http://softwareplusplus.files.wordpress.com/2011/03/jeff_stats.png?w=468&#038;h=257" alt="Query Stats for Jeff's Approach" width="468" height="257" /></a><p class="wp-caption-text">Jeff&#039;s Approach (for comparison)</p></div>
<div id="attachment_2276" class="wp-caption aligncenter" style="width: 478px"><a href="http://softwareplusplus.files.wordpress.com/2011/03/recursive_stats.png"><img class="size-full wp-image-2276 " title="Query Stats for Recursive Approach" src="http://softwareplusplus.files.wordpress.com/2011/03/recursive_stats.png?w=468&#038;h=257" alt="Query Stats for Recursive Approach" width="468" height="257" /></a><p class="wp-caption-text">Recursive Approach (Ugh!)</p></div>
<p style="text-align:left;">So, although it was a fun exercise, I have to concede this one. If performance is a major consideration (and when isn&#8217;t it?) then Jeff actually has a superior technique. Here is an example query using that technique, just be careful to understand the potential side-effects if you use it.</p>
<p><pre class="brush: sql; gutter: false; toolbar: true; wrap-lines: false;">
 SELECT REPLACE(REPLACE(REPLACE(LTRIM(RTRIM(sometext)),'  ',' '+ CHAR(7)) , CHAR(7)+' ',''), CHAR(7),'') AS CleanString
 FROM SpacesTest
 WHERE CHARINDEX('  ',sometext) &gt; 0
</pre></p>
<h2 style="text-align:left;">Feedback</h2>
<p>Given how dramatic the difference is for a similar operation, I have to think that maybe I am missing an optimization on my recursive solution that could reign in the performance. If you see anything I&#8217;m missing that might help my solution in terms of performance please let me know in the comments.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/softwareplusplus.wordpress.com/2214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/softwareplusplus.wordpress.com/2214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/softwareplusplus.wordpress.com/2214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/softwareplusplus.wordpress.com/2214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/softwareplusplus.wordpress.com/2214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/softwareplusplus.wordpress.com/2214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/softwareplusplus.wordpress.com/2214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/softwareplusplus.wordpress.com/2214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/softwareplusplus.wordpress.com/2214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/softwareplusplus.wordpress.com/2214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/softwareplusplus.wordpress.com/2214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/softwareplusplus.wordpress.com/2214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/softwareplusplus.wordpress.com/2214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/softwareplusplus.wordpress.com/2214/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2214&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://improvingsoftware.com/2011/03/21/replacing-multiple-spaces-in-a-string-with-a-single-space-in-sql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccddf43f6a7a99378f32a0c39c3f8733?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">JohnFx</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2011/03/jeff_stats.png" medium="image">
			<media:title type="html">Query Stats for Jeff&#039;s Approach</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2011/03/recursive_stats.png" medium="image">
			<media:title type="html">Query Stats for Recursive Approach</media:title>
		</media:content>
	</item>
		<item>
		<title>How to join on memo fields in Microsoft Access</title>
		<link>http://improvingsoftware.com/2011/03/15/how-to-join-on-memo-fields-in-microsoft-access/</link>
		<comments>http://improvingsoftware.com/2011/03/15/how-to-join-on-memo-fields-in-microsoft-access/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 15:58:43 +0000</pubDate>
		<dc:creator>johnfx</dc:creator>
				<category><![CDATA[How To...]]></category>
		<category><![CDATA[Technology Tips]]></category>
		<category><![CDATA[MSAccess]]></category>
		<category><![CDATA[Queries]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://improvingsoftware.com/?p=2203</guid>
		<description><![CDATA[Rambling Intro, Nostalgia, and Crankiness This week I got a request troubleshoot a legacy Microsoft Access application that has been floating around our company for ages, but still gets used daily because dang it, it does the job and always has. Seems like most companies that are standardized on MS Office have a few of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2203&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Rambling Intro, Nostalgia, and Crankiness</h2>
<p>This week I got a request troubleshoot a legacy Microsoft Access application that has been floating around our company for ages, but still gets used daily because dang it, it does the job and always has. Seems like most companies that are standardized on MS Office have a few of these lurking out on the network.</p>
<p>Earlier in my career I did a ton of work in MS Access and have garnered a reputation within my company for being an expert in this oft maligned platform so I got the call to look into the problem. It had been quite a while since I&#8217;d done any real work on MS Access and I&#8217;d forgotten about how quirky it could be. Also, I am more than a little disappointed at how Microsoft has mangled the UI of my old friend Access in the 2007 version. It is almost painful to work with it as a power-user in the current incarnation.</p>
<h2>The Problem</h2>
<p>So anyway, the issue turned out to be that someone increased the length of a field in the underlying SQL Server table linked into the Access application. They increased it past the magical border (255 characters) between what Access considers a text and a memo field, which imposed new limits on how it could be used. In particular, Access doesn&#8217;t allow either end of a join in a query to be a memo field.</p>
<div id="attachment_2205" class="wp-caption aligncenter" style="width: 478px"><a href="http://softwareplusplus.files.wordpress.com/2011/03/joinmemo.png"><img class="size-full wp-image-2205" title="Join on Memo Fields" src="http://softwareplusplus.files.wordpress.com/2011/03/joinmemo.png?w=468&#038;h=227" alt="Can't join on memo fields" width="468" height="227" /></a><p class="wp-caption-text">This won&#039;t fly, McFly</p></div>
<h2>The Solution</h2>
<p>The solution is painfully simple. So much so that I have to wonder why Access doesn&#8217;t just do it behind the scenes. Perhaps it is just trying to discourage you from building databases that link on big text fields for your own good (see &#8220;The Caveat&#8221; below).</p>
<p>The trick is to move the join into the WHERE clause of the query  like so:</p>
<div id="noIframeDiv3cf7f9f9-36ce-433c-8937-c3648f5a2f53" style="display:block;margin:0;">
<pre>
<div><span style="color:#0000ff;">SELECT<span style="color:#000000;"> Table1.</span><span style="color:#808080;">*</span><span style="color:#000000;">, Table2.</span><span style="color:#808080;">*</span><span style="color:#000000;">
</span><span style="color:#0000ff;">FROM</span><span style="color:#000000;"> Table1, Table2
</span><span style="color:#0000ff;">WHERE</span><span style="color:#000000;"> (Table1.MemoField</span><span style="color:#808080;">=</span><span style="color:#000000;">table2.MemoField);</span></span></div>
</pre>
<p>Here is the same query in the query builder for those of you who prefer it to the SQL view:</p>
<div id="attachment_2206" class="wp-caption aligncenter" style="width: 457px"><a href="http://softwareplusplus.files.wordpress.com/2011/03/nojoinmemo.png"><img class="size-full wp-image-2206" title="Joining memo fields in Access" src="http://softwareplusplus.files.wordpress.com/2011/03/nojoinmemo.png?w=468" alt="Graphical display of query"   /></a><p class="wp-caption-text">Remove the join between the tables and add a criterion</p></div>
<p>Access will raise nary a complaint if you run this query which is logically equivalent to the one it abhorred. That&#8217;s all there is to it.</p>
</div>
<h2>The Caveat</h2>
<p>A final note. It is a definite <a title="Database Smells, Redneck Style!" href="http://improvingsoftware.com/2009/05/19/database-smells-redneck-style/">database smell</a> for an application to be joining tables on long text fields and will likely be the source of some performance issues in a database of non-trivial size. However, as was the case for the application I was tweaking, joining on long text fields is sometimes necessary in queries used for data clean-up, validation, or replication.  Still, use this type of join with caution avoiding it whenever possible.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/softwareplusplus.wordpress.com/2203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/softwareplusplus.wordpress.com/2203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/softwareplusplus.wordpress.com/2203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/softwareplusplus.wordpress.com/2203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/softwareplusplus.wordpress.com/2203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/softwareplusplus.wordpress.com/2203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/softwareplusplus.wordpress.com/2203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/softwareplusplus.wordpress.com/2203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/softwareplusplus.wordpress.com/2203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/softwareplusplus.wordpress.com/2203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/softwareplusplus.wordpress.com/2203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/softwareplusplus.wordpress.com/2203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/softwareplusplus.wordpress.com/2203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/softwareplusplus.wordpress.com/2203/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2203&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://improvingsoftware.com/2011/03/15/how-to-join-on-memo-fields-in-microsoft-access/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccddf43f6a7a99378f32a0c39c3f8733?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">JohnFx</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2011/03/joinmemo.png" medium="image">
			<media:title type="html">Join on Memo Fields</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2011/03/nojoinmemo.png" medium="image">
			<media:title type="html">Joining memo fields in Access</media:title>
		</media:content>
	</item>
		<item>
		<title>Usability Hall of Shame &#8211; AutoCorrect</title>
		<link>http://improvingsoftware.com/2011/02/14/usability-hall-of-shame-autocorrect/</link>
		<comments>http://improvingsoftware.com/2011/02/14/usability-hall-of-shame-autocorrect/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 21:42:30 +0000</pubDate>
		<dc:creator>johnfx</dc:creator>
				<category><![CDATA[Fail]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[autocorrect]]></category>

		<guid isPermaLink="false">http://improvingsoftware.com/?p=2161</guid>
		<description><![CDATA[Cupertino, we have a problem. Q: How do you know when your software has a usability problem? A: When someone creates an entire humor site dedicated to mocking it. Okay, you might have said something involving reports from the usability testing, or maybe even some axiomatic list of UX smells. However, if you ever find [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2161&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Cupertino, we have a problem.</h2>
<p><strong>Q: How do you know when your software has a usability problem?</strong></p>
<p>A: When someone creates an entire <a title="Damn You Auto-Correct" href="http://damnyouautocorrect.com/" target="_blank">humor site</a> dedicated to mocking it.</p>
<p><a href="http://damnyouautocorrect.com/"><img class="size-medium wp-image-2162 alignright" title="autocorrect" src="http://softwareplusplus.files.wordpress.com/2011/02/autocorrect.jpg?w=216&#038;h=300" alt="" width="216" height="300" /></a></p>
<p>Okay, you might have said something involving reports from the usability testing, or maybe even some axiomatic list of <a title="Refactoring the User Experience" href="http://www.uxmatters.com/mt/archives/2009/05/refactoring-the-user-experience.php">UX smells</a>. However, if you ever find that a piece of software you wrote has inspired an entire new category of parodic <a title="Fun with iPhone Autocorrect" href="http://www.humor-articles.com/fun-with-iphone-autocorrect/">humor</a>, there just <em>might </em>be a problem.</p>
<h2>How has it come to this?</h2>
<p>The emergence of this UX gaffe leaves me incredulous for a number of reasons. First, one of the biggest offending implementations is baked into iOS, a product of a company that gets a lot of <a title="Usability Analysis of Apple.com. Why is it so good?" href="http://www.spoonfeddesign.com/usability-analysis-of-applecom-why-is-it-so-good">respect</a> for designing great interfaces. Secondly, and more importantly, most of the Mobile OS platforms with this issue have gone through several major upgrades and not fixed the problem despite all the <a title="Smart Phones Make us Look Dumb with Auto-Correct" href="http://www.npr.org/2011/01/13/132904838/thanks-autocorrect-smart-phones-make-us-look-dumb">bad press</a> about it.</p>
<div id="attachment_2168" class="wp-caption aligncenter" style="width: 517px"><a href="http://softwareplusplus.files.wordpress.com/2011/02/autocorrectgoogle.png"><img class="size-full wp-image-2168 " title="Auto-Correct Google Search" src="http://softwareplusplus.files.wordpress.com/2011/02/autocorrectgoogle.png?w=468" alt=""   /></a><p class="wp-caption-text">Fail x 439,000</p></div>
<h2>What&#8217;s the Problem?</h2>
<p>So to reel this conversation back in, and make it instructional and not just another ranting voice on the Internet that the developers of this software will ignore, let&#8217;s talk about what it is about the auto-correct feature on your cell phone that makes it such a usability disaster.</p>
<p>The core problem is that it violates the usability principle that the user should always feel like they are in control of the software.</p>
<blockquote><p>The users of your software should be the drivers, not the passengers. Ask Toyota how their &#8216;users&#8217; felt about their products deciding independently that more speed might be nice .</p></blockquote>
<p>If you are going to make your spelling checker jump in and autonomously decide it knows what the typist meant to say, it had better be right 100% of the time.  Is that bar too high? Well then stop making your app take over the controls. A well behaved app is heard and not stomping all over my carefully written prose and/or review of the wing place where I am currently receiving inferior service.</p>
<p>Not only does this implementation of auto-correct make the user feel impotent, it also violates the usability commandment that the user&#8217;s input is sacred. Violations of this principle contribute mightily to the computer-phobic person&#8217;s notion that the machine is going all <a title="SkyNet" href="http://terminator.wikia.com/wiki/Skynet">SkyNet </a>on them.</p>
<p><strong>Extra Credit:</strong> Why do you think applications like MS Office that move your menu items around by usage frequency so infuriating? How about browser pop-ups?</p>
<h2>Reinventing the Wheel &#8211; Let&#8217;s try square this time!</h2>
<p>This would all be more excusable if a perfectly user-friendly auto-correct interface didn&#8217;t already exist. What&#8217;s more aggravating is that the existing workable system is so close to the new broken version that it is inconceivable that the designers of the new version weren&#8217;t familiar with the existing one.</p>
<p>Consider for a moment how auto-correct is implemented in MS Office, Blackberry OS, and the Firefox spell-checker. In almost identical fashion it gives you a list of suggested alternatives for the suspected misspelled word.  The key difference is that it SUGGESTS, but doesn&#8217;t CORRECT the user&#8217;s text unless the user takes affirmative action. This puts the user fully in control of the system, which makes them happy. Sure some typos may slip by the user, but if you are giving good enough visual indicators that should be minimized.</p>
<div id="attachment_2182" class="wp-caption aligncenter" style="width: 478px"><a href="http://softwareplusplus.files.wordpress.com/2011/02/autocorrectexample.png"><img class="size-full wp-image-2182" title="Auto-Correct Corrected" src="http://softwareplusplus.files.wordpress.com/2011/02/autocorrectexample.png?w=468&#038;h=351" alt="" width="468" height="351" /></a><p class="wp-caption-text">If only auto-correct had an anti-troll feature...</p></div>
<h2 style="text-align:left;">Is Anyone Listening?</h2>
<p>Perhaps I&#8217;ve completely missed the point here, and there is a good reason why something that was routine on my old Blackberry is nigh impossible on the other smart phone platforms. If you have any inside scoop, or just have a convincing theory to share I&#8217;d love to hear about it in the comments. If you just want to complain about it, that&#8217;s fine too, maybe we can make this square wheel squeaky enough to get some satisfaction.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/softwareplusplus.wordpress.com/2161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/softwareplusplus.wordpress.com/2161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/softwareplusplus.wordpress.com/2161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/softwareplusplus.wordpress.com/2161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/softwareplusplus.wordpress.com/2161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/softwareplusplus.wordpress.com/2161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/softwareplusplus.wordpress.com/2161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/softwareplusplus.wordpress.com/2161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/softwareplusplus.wordpress.com/2161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/softwareplusplus.wordpress.com/2161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/softwareplusplus.wordpress.com/2161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/softwareplusplus.wordpress.com/2161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/softwareplusplus.wordpress.com/2161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/softwareplusplus.wordpress.com/2161/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2161&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://improvingsoftware.com/2011/02/14/usability-hall-of-shame-autocorrect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccddf43f6a7a99378f32a0c39c3f8733?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">JohnFx</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2011/02/autocorrect.jpg?w=216" medium="image">
			<media:title type="html">autocorrect</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2011/02/autocorrectgoogle.png" medium="image">
			<media:title type="html">Auto-Correct Google Search</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2011/02/autocorrectexample.png" medium="image">
			<media:title type="html">Auto-Correct Corrected</media:title>
		</media:content>
	</item>
		<item>
		<title>Concatenating Strings &#8211; You&#8217;re still doing it wrong.</title>
		<link>http://improvingsoftware.com/2011/02/11/concatenating-strings-youre-still-doing-it-wrong/</link>
		<comments>http://improvingsoftware.com/2011/02/11/concatenating-strings-youre-still-doing-it-wrong/#comments</comments>
		<pubDate>Sat, 12 Feb 2011 00:22:56 +0000</pubDate>
		<dc:creator>johnfx</dc:creator>
				<category><![CDATA[Technology Tips]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://improvingsoftware.com/?p=2100</guid>
		<description><![CDATA[The dangers of cargo cult programming demonstrated by analyzing common myths about string concatenation techniques.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2100&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A common anti-pattern I see from novice programmers is the tendency to read a coding tip somewhere, assume it to be a universal truth, and immediately start applying it everywhere in their code without fully understanding it. Usually the coding tip relates to optimization and is interpreted by the coder as &#8220;X is faster than Y, so always do Y instead of X.&#8221; This fallacy is particularly rampant with respect to the different approaches for concatenating strings.</p>
<div id="attachment_2133" class="wp-caption aligncenter" style="width: 310px"><a href="http://softwareplusplus.files.wordpress.com/2011/02/pticars-1.jpg"><img class="size-medium wp-image-2133 " src="http://softwareplusplus.files.wordpress.com/2011/02/pticars-1.jpg?w=300&#038;h=225" alt="Car with Wing" width="300" height="225" /></a><p class="wp-caption-text">But it works on race cars....</p></div>
<p>I&#8217;m not writing this article to chastise the fledgling programmer who has fallen into this trap, nor is this intended as a how-to article on optimizing your code. Heaven knows there the internet is lousy with articles about the most efficient way to cram strings together. I will address the problems associated with some of the mythology about string concatenation, but my primary goal will be to encourage critical thinking and healthy skepticism for silver bullet programming techniques.</p>
<h2>The Symptom</h2>
<p>Though I possess no paranormal super-powers, I do believe I can read the mind of another human when I see code that looks like this:</p>
<p><pre class="brush: csharp;">
    StringBuilder WelcomeMessage = new StringBuilder();
    WelcomeMessage.Append(&quot;Hello &quot;);
    WelcomeMessage.Append(firstName);
    WelcomeMessage.Append(&quot; &quot;);
    WelcomeMessage.Append(LastName);
    WelcomeMessage.Append(&quot;!\n&quot;)
</pre></p>
<p>My spirit guide informs me that that programmer responsible for this code remembers reading <em><strong>somewhere </strong></em>that  &lt;insert programming language&gt; is really inefficient at concatenating strings, but you can overcome that limitation by using the StringBuilder class. Based on this information he/she replaces every string concatenation operator with this clever technique leaving a <a title="Coding Horror: Code Smells" href="http://www.codinghorror.com/blog/2006/05/code-smells.html" target="_blank">scent trail through the code</a> that experienced programmers can smell from miles away.</p>
<h2>Problem 1: Premature Optimization is Procrastination</h2>
<p>Sure, you want ALL of your code to perform well, but experienced programmers understand that their time is valuable and best spent on activities that deliver actual business value. Premature optimization and its ugly cousin <a title="Coding Horror: Micro-Optimization and Meatballs" href="http://www.codinghorror.com/blog/2005/01/micro-optimization-and-meatballs.html" target="_blank">Micro Optimization</a> are almost always a waste of time. I understand how tempting it is to justify in your head that you could squeeze a little bit more performance out of your app by re-factoring the whole thing you learned in the blog post you read today, especially since it can be like a mini-vacation for your mind from the really complex issues you really should be working on, but be strong and resist!</p>
<p>As a rule of thumb: If it isn&#8217;t worth creating a jig to profile the performance gains you expect to get from optimization re-factoring, then it isn&#8217;t worth the time to do the re-factoring in the first place, plus it is risky because you won&#8217;t notice that your supposed &#8220;optimization&#8221; actually hurt performance.</p>
<p>More on that later.</p>
<h2>Problem 2: Cookie Cutter Optimizations Assume the Compiler is Stupid</h2>
<p>If you could universally make string concatenation faster by applying a simple formula then the compiler would probably already be applying the transformation anyway. Granted, I think this point is lost on some novice programmers who only have experience in higher level languages.</p>
<p>For them, I&#8217;ll clarify with this point.</p>
<blockquote><p>Your program is running the compiler&#8217;s interpretation of your code. Not your actual code.</p></blockquote>
<p>With that in mind, to think that the StringBuilder approach always runs faster would require you to believe that the people who wrote the programming language were smart enough to make string concatenation fast when they created the StringBuilder class, but forgot how to do it when they built the concatenation operator.</p>
<p><strong>Pop Quiz:</strong> Does this code give you any heartburn? Why?</p>
<p><pre class="brush: csharp;">
    string querySQL = &quot;SELECT * &quot; +
                      &quot;FROM myTable &quot; +
                      &quot;WHERE (ID=5)&quot;;
</pre></p>
<p>If you said yes because it isn&#8217;t worth incurring the cost of concatenation for code readability then you aren&#8217;t giving the compiler enough credit.</p>
<p>Here is the MSIL output for the above statement:</p>
<p><pre class="brush: plain;">
ldstr      &quot;SELECT * FROM myTable WHERE (ID=5)&quot;
</pre></p>
<p>Amazing, huh?</p>
<p>Compilers are written to do the complex task of  reading your code and interpreting what it means. Figuring out that a series of constant strings can be combined is child&#8217;s play.</p>
<h2>Problem 3: If you don&#8217;t understand it, you&#8217;ll do it wrong</h2>
<p><a title="Cargo Cult Programming (Wikipedia)" href="http://en.wikipedia.org/wiki/Cargo_cult_programming" target="_blank">Cargo Cult programming</a> is a derisive term for doing things in your program because you think you need to, but don&#8217;t understand (or have a vague notion of)  the underlying reason. It is really bad practice to adopt a technique without asking enough &#8220;why&#8221; questions to grasp the reason using it is desirable.</p>
<p>As an example, let&#8217;s dissect the premise that string concatenation using operators is slow and should be replaced by StringBuilders.</p>
<p><strong>Q: Why do some claim that string concatenation with operators is slow?</strong><br />
<strong> </strong> In many garbage collected languages (Java/.NET) string objects are  <a title="Immutable Objects" href="http://en.wikipedia.org/wiki/Immutable_object" target="_blank">immutable</a>, meaning you can&#8217;t change them. So when you append more content into an existing string the program must internally create a new string and copy the old and new contents into it. The extra effort to create, destroy and garbage collect the extra string objects has the potential to create more work for your program and can degrade performance if done excessively.</p>
<p><strong>Q: How does the StringBuilder help?</strong><br />
<strong> </strong>The StringBuilder class is implemented as a mutable memory buffer that typically has extra unused space allocated so that concatenations can be made in place without the need to create extra objects to juggle the data.</p>
<p><strong>Q: How much extra space does it reserve? What happens if I append more content than will fit in the unused space?</strong><br />
<strong></strong>By default (in .NET) 16 characters, unless you specify differently in the constructor. If you append more data than there is space, the StringBuilder will behave much like a String object creating a new StringBuilder object with double the existing capacity then copy over the data.</p>
<blockquote><p>You: Wait, what?</p></blockquote>
<p>You mean that you have been using StringBuilder with the default constructor and then appending more than 16 characters to it?</p>
<p>Yeah, well if you are lucky you&#8217;ll be no worse off than if you just used the &#8220;<em>evil</em>&#8221; string concatenation operators. However, due to that neat capacity doubling side-effect, your program might actually be locking up unnecessarily large chunks of memory on top of the additional work required to wrangle all the intermediary objects. Perhaps it is worth investigating and setting the initial capacity of that StringBuilder to avoid such nastiness.</p>
<p><strong>Bonus: </strong>Now that you understand the potential performance benefit is based (at least partly) on mutability, you will see that other string optimization opportunities may exist whenever existing strings need to be modified, not just appended to.</p>
<h2>Final Thoughts</h2>
<p>Again, the point of all this isn&#8217;t about strings, or optimization, or any of that. It is about taking the time to understand what you are doing to avoid falling prey to the potentially harmful myths that are enthusiastically passed around by programmers (see also &#8220;<a title="Without ORDER BY, there is no default sort order. " href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2009/05/20/without-order-by-there-is-no-default-sort-order.aspx" target="_blank">The database sorts by the clustered index if you don&#8217;t specify an Ordering</a>&#8220;).</p>
<p>In any event, I&#8217;m curious as to how many of my readers actually have at one time subscribed to the cargo cult programing meme of &#8220;StringBuilder is always better&#8221;. Please let me know in the comments.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/softwareplusplus.wordpress.com/2100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/softwareplusplus.wordpress.com/2100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/softwareplusplus.wordpress.com/2100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/softwareplusplus.wordpress.com/2100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/softwareplusplus.wordpress.com/2100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/softwareplusplus.wordpress.com/2100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/softwareplusplus.wordpress.com/2100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/softwareplusplus.wordpress.com/2100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/softwareplusplus.wordpress.com/2100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/softwareplusplus.wordpress.com/2100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/softwareplusplus.wordpress.com/2100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/softwareplusplus.wordpress.com/2100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/softwareplusplus.wordpress.com/2100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/softwareplusplus.wordpress.com/2100/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2100&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://improvingsoftware.com/2011/02/11/concatenating-strings-youre-still-doing-it-wrong/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccddf43f6a7a99378f32a0c39c3f8733?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">JohnFx</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2011/02/pticars-1.jpg?w=300" medium="image">
			<media:title type="html">Car with Wing</media:title>
		</media:content>
	</item>
		<item>
		<title>Problem Solving 101: First, Understand the Problem</title>
		<link>http://improvingsoftware.com/2010/12/09/problem-solving-101-first-understand-the-problem/</link>
		<comments>http://improvingsoftware.com/2010/12/09/problem-solving-101-first-understand-the-problem/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 23:54:13 +0000</pubDate>
		<dc:creator>johnfx</dc:creator>
				<category><![CDATA[The Software Development Process]]></category>
		<category><![CDATA[electronic voting]]></category>
		<category><![CDATA[Problem solving]]></category>

		<guid isPermaLink="false">http://improvingsoftware.com/?p=2062</guid>
		<description><![CDATA[The Null Solution In my previous article, Collaborative Problem Solving, I talked about the importance of questioning assumptions and reconfirming your understanding of the problem when you hit a brick wall during design or troubleshooting of a system. In fact, one of my favorite strategies for tackling a tough design problem is take the  nihilist [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2062&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>The Null Solution</h2>
<p>In my previous article, <a title="Problem Solving 101: Collaborative Problem Solving" href="http://improvingsoftware.com/2010/12/08/problem-solving-101-collaborative-problem-solving-techniques/">Collaborative Problem Solving</a>, I talked about the importance of questioning assumptions and reconfirming your understanding of the problem when you hit a brick wall during design or troubleshooting of a system. In fact, one of my favorite strategies for tackling a tough design problem is take the  nihilist approach. In the words of the Zen Master&#8230;</p>
<blockquote><p>Remember that there is no code faster than no code.</p>
<p style="text-align:right;">- <a href="http://www.amazon.com/gp/product/0201408880?ie=UTF8&amp;tag=sofblo0e-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0201408880">Taligent&#8217;s Guide to Designing Programs</a><img class="alignright" style="border:none!important;margin:0!important;" src="http://www.assoc-amazon.com/e/ir?t=sofblo0e-20&amp;l=as2&amp;o=1&amp;a=0201408880" border="0" alt="" width="1" height="1" /></p>
</blockquote>
<p>My corrolary to this is that there is also no code <strong>simpler </strong>than no code. So when confronted with a complex design challenge or optimization problem, my first question is always &#8220;How can we get away without implementing this at all?&#8221; Granted, this only works about 20% of the time, but when we can step back and realize that a particularly pernicious problem has just vaporized it is a wonderful thing.</p>
<p>I&#8217;m sure that some may be  incredulous about the idea that this ever works at all. I mean, why would anyone have even started working on a problem that didn&#8217;t need to be solved? The answer is that only in rare cases does this approach reveal that the entire project was unnecessary, although I have that happen. More often it just reveals that the developer has ventured too far down a dead-end path and is working exclusively on meta-problems that can be eliminated by just backing up a few steps.</p>
<p>For example, this <a title="How can I compact lots of small Try-Catch blocks when handling exceptions in C#?" href="http://stackoverflow.com/questions/4400533/how-can-i-compact-lots-of-small-try-catch-blocks-when-handling-exceptions-in-c">Stack Overflow Question</a>, is a good example of a meta-problem that can be eliminated by taking a step back and reconsidering how to avoid throwing errors instead of how to ignore them as explained in this <a title="http://stackoverflow.com/questions/4400533/how-can-i-compact-lots-of-small-try-catch-blocks-when-handling-exceptions-in-c/4400611#4400611" href="&quot;Just use TryParse instead of parse...&quot;">answer</a>.</p>
<h2>Re-evaluating the Problem</h2>
<p>What got me started on this two day rant about problem solving approaches was this really <a title="David Bismark: E-Voting Without Fraud" href="http://www.ted.com/talks/david_bismark_e_voting_without_fraud.html?awesm=on.ted.com_8l0H&amp;utm_campaign=david_bismark_e_voting_without_fraud&amp;utm_content=ted.com-talkpage&amp;utm_medium=on.ted.com-twitter&amp;utm_source=twitter.com">insightful idea</a> for solving some of the core issues with implementing an voting system. It was a really great example of how re-examining the core problem led to a solution to a seemingly intractable problem.  Here&#8217;s a quick breakdown on the dilemma.</p>
<p><strong>Goals:</strong> An voting system must satisfy these criteria (among others)</p>
<ol>
<li>Voters must be able to anonymously cast their votes.</li>
<li>Voters can cast zero or one ballot, but never more than one.</li>
<li>Voters must not be able to prove who they voted for (to preclude vote buying).</li>
<li>Voters should be able to confirm their vote was properly recorded for each candidate they picked.</li>
</ol>
<p><strong>Problem:</strong> If a voter can confirm who they voted for then they have the means to prove (and receive remuneration) for voting for a particular candidate.</p>
<p>The problem that has stumped many, including myself in analyzing this problem is that requirements (3) and (4) are apparently incompatible.  How can you give the person a way to confirm their vote without being able to prove their vote to another person?</p>
<p><strong>The Solution:</strong> The solution that David Bismark came up with was fairly straightforward once he realized that we were looking at requirement (4) incorrectly. Consider this clarification of that requirement.</p>
<p style="padding-left:30px;">4. Voters should be able to confirm their vote was properly recorded <span style="color:#ff0000;"><del>for each candidate they picked</del></span> <strong>the way they marked it</strong>.</p>
<p>Under this revised understanding of the problem, the solution became more straightforward. Essentially his solution involves randomizing the order of the names on the ballot, after voting the ballot is torn in half and the names part is shredded. The bubble-candidate correlation is encrypted on the ballot to prevent tampering, but allow the vote to be tabulated.</p>
<p style="text-align:center;"><a href="http://softwareplusplus.files.wordpress.com/2010/12/voting.png"><img class="aligncenter size-medium wp-image-2088" title="voting" src="http://softwareplusplus.files.wordpress.com/2010/12/voting.png?w=300&#038;h=125" alt="" width="300" height="125" /></a></p>
<p>The voter then can check (perhaps online) that the bubbles they marked were counted, but no longer see which candidate corresponds with each bubble. Assuming they remember the order of the candidates, they can confirm their voted counted but not prove who they voted for. Voila! Brilliant!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/softwareplusplus.wordpress.com/2062/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/softwareplusplus.wordpress.com/2062/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/softwareplusplus.wordpress.com/2062/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/softwareplusplus.wordpress.com/2062/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/softwareplusplus.wordpress.com/2062/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/softwareplusplus.wordpress.com/2062/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/softwareplusplus.wordpress.com/2062/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/softwareplusplus.wordpress.com/2062/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/softwareplusplus.wordpress.com/2062/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/softwareplusplus.wordpress.com/2062/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/softwareplusplus.wordpress.com/2062/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/softwareplusplus.wordpress.com/2062/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/softwareplusplus.wordpress.com/2062/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/softwareplusplus.wordpress.com/2062/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2062&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://improvingsoftware.com/2010/12/09/problem-solving-101-first-understand-the-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccddf43f6a7a99378f32a0c39c3f8733?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">JohnFx</media:title>
		</media:content>

		<media:content url="http://www.assoc-amazon.com/e/ir?t=sofblo0e-20&#38;l=as2&#38;o=1&#38;a=0201408880" medium="image" />

		<media:content url="http://softwareplusplus.files.wordpress.com/2010/12/voting.png?w=300" medium="image">
			<media:title type="html">voting</media:title>
		</media:content>
	</item>
		<item>
		<title>Problem Solving 101: Collaborative Problem Solving</title>
		<link>http://improvingsoftware.com/2010/12/08/problem-solving-101-collaborative-problem-solving-techniques/</link>
		<comments>http://improvingsoftware.com/2010/12/08/problem-solving-101-collaborative-problem-solving-techniques/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 01:38:25 +0000</pubDate>
		<dc:creator>johnfx</dc:creator>
				<category><![CDATA[The Software Development Process]]></category>
		<category><![CDATA[Problem solving]]></category>

		<guid isPermaLink="false">http://improvingsoftware.com/?p=2023</guid>
		<description><![CDATA[As a software development manager, I am frequently visited by developers who are spinning their wheels on a design problem or running out of ideas while troubleshooting an application.  I&#8217;ve developed a reputation as a problem solver because most of these visits end with a eureka moment that clears the logjam for the developer. Although [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2023&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As a software development manager, I am frequently visited by developers who are spinning their wheels on a design problem or running out of ideas while troubleshooting an application.  I&#8217;ve developed a reputation as a problem solver because most of these visits end with a eureka moment that clears the logjam for the developer. Although I do like to think that I&#8217;m a reasonably good troubleshooter/architect,  I have accrued quite a bit of unearned reputation from these impromptu brainstorming sessions as a problem solver. A more fair assessment of my contribution might be that I am just a really good sounding board.</p>
<p>I&#8217;m sure everyone reading this can remember an instance where you went to ask someone a question and simply the act of asking it aloud made you realize the answer. Consider for a moment why this technique works, and why it often works better when the other person has little advance knowledge of  the issue. To bring that other person into the discussion you are forced to rewind  your brain back to when you started working on the problem eschewing all  of the clutter and complexity that you have added since you&#8217;ve been working on it. Then you must revisit each of the steps you have taken justifying each decision and restating each assumption.</p>
<p>So why should revisiting the history of the problem be effective? After all, having the same person answer the same intermediate questions ought to bring that person to the same conclusion, right? If this were true, then the sounding board approach would be a waste of time, which we know is not the case from anecdotal evidence. The reason you arrive at a different answer is that unlike the first time through, you now have the benefit of foresight and are far less likely to take  a path that you know will lead you through the brambles.</p>
<p>The longer you walk down those brambly paths the easier it is to mentally commit to pressing forward. On an intellectual level we understand the<a title="The Sunk Cost Fallacy" href="http://www.skepdic.com/sunkcost.html"> sunk cost fallacy</a>, but are still susceptible to it and can form mental blocks that make it discomforting to backtrack for more than one or two forks in the road. This is why we need the guide to force us to rethink the whole journey and each decision along the way.</p>
<h2>Tips for Being a Good Sounding Board</h2>
<div id="attachment_2063" class="wp-caption alignright" style="width: 110px"><a href="http://softwareplusplus.files.wordpress.com/2010/12/bieber.jpg"><img class="size-thumbnail wp-image-2063" title="Bieber" src="http://softwareplusplus.files.wordpress.com/2010/12/bieber.jpg?w=100&#038;h=150" alt="" width="100" height="150" /></a><p class="wp-caption-text">I&#039;m Listening.</p></div>
<p>Face it, there are times when a poster of Justin Bieber would be exactly as productive as a sounding board as you or anyone else on the team. The core problem is sometimes just so obvious that saying it out loud is enough to expose the flaws in the current approach. I&#8217;m going to save the advice on how to be more like Justin for a future article and focus now on how you can be a better guide for helping out on the thornier problems.</p>
<ol>
<li><strong>Establish yourself as a devil&#8217;s advocate</strong> &#8211; The rest of these tips taken in the wrong context can easily put the person defensive. Establish that you are going to ask a bunch of questions, some naive, some pointed, but that your goal is to help them re-verify their assumptions, not to promote an alternate idea or criticize their approach.<br />
<strong> </strong></li>
<li><strong>Be Kind, Rewind </strong>- Even if you know the back-story, ask lots of &#8220;why&#8221; questions and continue pushing back towards the root problem. Help them fight the tendency to revisit only the last few decisions.<em> &#8220;You are de-normalizing the table for performance? Why did you need to do that?&#8221;</em></li>
<li><strong>Don&#8217;t let them linger on meta-problems</strong> &#8211; When a problem seems too big to hold in your brain, it&#8217;s tempting to seek respite by focusing on manageable meta-problems. While those problems may need solving, they are distractions from the real issue that is blocking progress. When the person lingers on details or raises meta-problems, keep rewinding.<strong> </strong></li>
<li><strong>Ask Probing Questions </strong>- Make them talk through each decision and ask stupid questions. Apply extra scrutiny when the developer clearly thinks a decision was easy or obvious. When we think things are obvious, we take mental shortcuts by avoiding thinking things through as thoroughly. Challenge assumptions, this is where problems hide.</li>
<li><strong>Use Reflective Listening</strong> &#8211; This is a <a title="More details on active listening" href="http://www.analytictech.com/mb119/reflecti.htm" target="_blank">communication technique</a> where you repeat back  a summary of what the other person just said to you to confirm understanding. Another benefit in this situation is that having the person hear their own ideas in another person&#8217;s voice/words may make it easier for them to be objective.</li>
<li><strong>Avoid injecting your own ideas</strong> &#8211; At some point you may have a great idea for a better approach. Keep it to yourself. It will just make them defensive and will undermine their sense of ownership of the problem, and inhibit their ability to understand the solution.</li>
<li><strong>Lead them to the answer</strong> &#8211; If they simply aren&#8217;t making progress and you know a good answer consider  leading them to the answer with a line of questioning that directs them instead of just hand feeding the information to them. They are more likely to take ownership if they feel they reached the conclusion, and people generally retain information more readily if they arrived at it by logic on their own. If you must resort to this, tread lightly with your tone and take extra care not to come off as pedantic.</li>
</ol>
<p>It may seem strange that my approach advocates being somewhat evasive with information or potential solutions. However, it is given in the context of a manager/mentor acting as a sounding board. In this role, your primary focus should be to create leverage by <strong>making things happen through your team</strong>. Any veteran manager will tell you that handing out answers routinely to technical problems is only going to make the line to your office longer and make you the bottleneck.  I strongly favor approaches that encourage critical thinking among developers and gives the glory to the developer instead of the esteemed leader. Trust me, it pays off in the long run.</p>
<p><strong><br />
</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/softwareplusplus.wordpress.com/2023/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/softwareplusplus.wordpress.com/2023/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/softwareplusplus.wordpress.com/2023/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/softwareplusplus.wordpress.com/2023/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/softwareplusplus.wordpress.com/2023/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/softwareplusplus.wordpress.com/2023/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/softwareplusplus.wordpress.com/2023/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/softwareplusplus.wordpress.com/2023/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/softwareplusplus.wordpress.com/2023/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/softwareplusplus.wordpress.com/2023/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/softwareplusplus.wordpress.com/2023/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/softwareplusplus.wordpress.com/2023/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/softwareplusplus.wordpress.com/2023/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/softwareplusplus.wordpress.com/2023/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=2023&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://improvingsoftware.com/2010/12/08/problem-solving-101-collaborative-problem-solving-techniques/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccddf43f6a7a99378f32a0c39c3f8733?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">JohnFx</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2010/12/bieber.jpg?w=100" medium="image">
			<media:title type="html">Bieber</media:title>
		</media:content>
	</item>
		<item>
		<title>Is Agile for Amateurs?</title>
		<link>http://improvingsoftware.com/2010/12/03/is-agile-for-amateurs/</link>
		<comments>http://improvingsoftware.com/2010/12/03/is-agile-for-amateurs/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 00:42:48 +0000</pubDate>
		<dc:creator>johnfx</dc:creator>
				<category><![CDATA[Managing Software Development]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[methodology]]></category>
		<category><![CDATA[opinion]]></category>

		<guid isPermaLink="false">http://improvingsoftware.com/?p=1094</guid>
		<description><![CDATA[I found myself discussing development practices with a manager of a local startup software company and was a little taken aback when he unequivocally proclaimed that they didn&#8217;t need agile because he had a team that consisted solely of extremely talented veteran programmers, with an average tenure of more than a decade. He claimed they [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=1094&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I found myself discussing development practices with a manager of a local startup software company and was a little taken aback when he unequivocally proclaimed that they didn&#8217;t need agile because he had a team that consisted solely of extremely talented veteran programmers, with an average tenure of more than a decade.</p>
<p>He claimed they knew what needed to be done and did it without any official methodology. In these parts we might call that &#8220;Cowboy Coding.&#8221;  His premise that following a standard methodology was meant for novice  teams or those with immature programmers who hadn&#8217;t gotten &#8220;into the  groove&#8221; of their careers.</p>
<div id="attachment_2057" class="wp-caption aligncenter" style="width: 310px"><a href="http://softwareplusplus.files.wordpress.com/2010/12/cowboycoder.jpg"><img class="size-medium wp-image-2057" title="Cowboy Coder" src="http://softwareplusplus.files.wordpress.com/2010/12/cowboycoder.jpg?w=300&#038;h=225" alt="" width="300" height="225" /></a><p class="wp-caption-text">Giddyup!</p></div>
<p>Before you trash the guy,  consider the following:</p>
<ul>
<li>The guy and his team really were hardcore. It was chock full of developers that I&#8217;d love to be able to lure over to my shop.</li>
<li>This guy had bootstrapped several start-up organizations and is extremely technically competent for a suit.</li>
<li>He based this statement on demonstrable results, working software that apparently was popular with his customers.</li>
</ul>
<p>How can you argue with results? Of course, I&#8217;m not absolutely sure about the veracity of his claims of success. In the context of our conversation it was conceivable he might have been exaggerating given that I currently work for a company that is a potential customer for his company&#8217;s product.</p>
<p>Personally, and despite these points I still tend to disagree. Even though he may be seeing success despite an unstructured development environment. I&#8217;d argue that the team may still be performing below their full potential and would still benefit from some flavor of an Agile approach.</p>
<p>It seems to me that Agile is <strong>better </strong>suited to teams with a lot of talent and experience, and if anything would be more problematic with a bunch of rookies. A core Agile concept is to let the development team self-organize, which implies a great deal of trust.  Agile is not about babysitting, and certainly not about command-and-control management. It is about communication, coordination, and frequent re-alignment with an emerging picture of the customer&#8217;s needs.</p>
<p>I&#8217;m curious what you guys think?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/softwareplusplus.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/softwareplusplus.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/softwareplusplus.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/softwareplusplus.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/softwareplusplus.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/softwareplusplus.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/softwareplusplus.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/softwareplusplus.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/softwareplusplus.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/softwareplusplus.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/softwareplusplus.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/softwareplusplus.wordpress.com/1094/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/softwareplusplus.wordpress.com/1094/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/softwareplusplus.wordpress.com/1094/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=improvingsoftware.com&amp;blog=7025486&amp;post=1094&amp;subd=softwareplusplus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://improvingsoftware.com/2010/12/03/is-agile-for-amateurs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ccddf43f6a7a99378f32a0c39c3f8733?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">JohnFx</media:title>
		</media:content>

		<media:content url="http://softwareplusplus.files.wordpress.com/2010/12/cowboycoder.jpg?w=300" medium="image">
			<media:title type="html">Cowboy Coder</media:title>
		</media:content>
	</item>
	</channel>
</rss>
