title: Obfuscated C# Code - What is the balance between concision and clarity?
body: <p>Years ago there used to be a contest to see who could produce the most obfuscated C code, and some of the results were dramatically unreadable. C was like that. You could really screw things up with the preprocessor in particular.</p>
  
  <p>However, many of the newer features of C# offer an amazing opportunity to obfuscate code to. I was wondering if anyone had an opinion on finding the right balance between concision and clarity in code. Let me offer one example for discussion, the task of filling items into a <code>ListView</code>. (Yes I know you can do it with data binding, but go with me here.)</p>
  
  <p>The control is two column to be filled with an array of</p>
  
  <pre class="lang-cs prettyprint-override"><code>struct Person
  {
      public string name;
      public string address;
  };
  </code></pre>
  
  <p>One, clear and simple way is this:</p>
  
  <pre><code>private void Fill(Person[] people)
  {
      foreach(Person person in people)
      {
          string[] columns = new string[2];
          columns[0] = person.name;
          columns[1] = person.address;            
          ListViewItem item = new ListViewItem(columns);
          listView1.items.Add(item);
      }
  }
  </code></pre>
  
  <p>Clear and simple to understand.</p>
  
  <p>I could also write it like this:</p>
  
  <pre><code>private void Fill(Person[] people)
  {
      foreach(Person person in people)
      {
          string[] columns = new string[] { person.name, person.address };
          ListViewItem item = new ListViewItem(columns);
          listView1.items.Add(item);
      }
  }
  </code></pre>
  
  <p>or even:</p>
  
  <pre><code>private void Fill(Person[] people)
  {
      foreach(var person in people) // Note use implicit typing here
      {
          listView1.items.Add(new ListViewItem(
          new string[] { person.name, person.address }));
      }
  }
  </code></pre>
  
  <p>Finally, I could also write it like this:</p>
  
  <pre><code>private void Fill(Person[] people)
  {
      Array.ForEach(people, item =&gt;
      listView1.items.Add(new ListViewItem(
      new string[] { person.name, person.address}));
  }
  </code></pre>
  
  <p>Each uses various new features of the language to a greater or lesser extent. How do you find the balance between concision and clarity? Should we have an annual Obfuscated C# contest?</p>