title: Useful mini patterns (not design patterns)
body: <p>My most used mini pattern is:</p>
  
  <pre><code>VideoLookup = new ArrayList  { new ArrayList { buttonVideo1, "Video01.flv" },
                                 new ArrayList { buttonVideo2, "Video02.flv" },
                                 new ArrayList { buttonVideo3, "Video03.flv" }, 
                                 new ArrayList { buttonVideo4, "Video04.flv" },
                                 new ArrayList { buttonVideo4, "Video04.flv" }
                               };
  </code></pre>
  
  <p>This means that rather than a switch statement with a case for each button I can instead just compare the button that was clicked with each item in the ArrayList. Then when I've found a match I launch the correct file (although the action that's the 2nd part the "lookup" could be a delegate or anything else).</p>
  
  <p>The main benefit is that I don't have the problem of remembering to add all the correct code for each switch statement case, I just add a new item to the lookup ArrayList.</p>
  
  <p><em>(Yes I know using an ArrayList isn't the best way to go, but it's old code. And I know that looping through an array each time isn't as efficient as using a switch statement, but this code isn't in a tight loop)</em></p>
  
  <p>Does anyone else have any mini-patterns they use that save time/effort or make code more readable? <em>They don't have to just be GUI related</em>.</p>
  
  <p><strong>Update:</strong> Don't copy this code, I knew it was bad, but I didn't realise how bad. Use something like this instead.</p>
  
  <pre><code>Hashtable PlayerLookup = new Hashtable();
  PlayerLookup.Add(buttonVideo1, "Video01.flv");
  PlayerLookup.Add(buttonVideo2, "Video02.flv");
  PlayerLookup.Add(buttonVideo3, "Video03.flv");
  PlayerLookup.Add(buttonVideo4, "Video04.flv");
  
  string fileName = PlayerLookup[currentButton].ToString();            
  </code></pre>