title: Refactoring; creating pseudo-primitives for your application domain
body: <p>How would you refactor this, keeping in mind that you have dozens more of such measurements to represent? It's kind of like changing an int to short or long or byte. Generic <code>unit&lt;T&gt;</code>? Implicit type conversion by via operator overloading? <code>ToType()</code> pattern? Abstract base class? <code>IConvertible</code>?</p>
  
  <pre><code>public class lb
  {
      private readonly float lbs;
      private readonly kg kgs;
  
      public lb(float lbs)
      {
          this.lbs = lbs;
          this.kgs = new kg(lbs * 0.45359237F);
      }
  
      public kg ToKg()
      {
          return this.kgs; 
      }
  
      public float ToFloat()
      {
          return this.lbs;
      }
  }
  
  public class kg 
  {
      private readonly float kgs;
      private readonly lb lbs;
  
      public kg(float kgs)
      {
          this.kgs = kgs;
          this.lbs = new lb(kgs * 2.20462262F);
      }
  
      public float ToFloat()
      {
          return this.kgs;
      }
  
      public lb ToLb()
      {
          return this.lbs;
      }
  }
  </code></pre>