title: strategy pattern in C#
body: <p>I've been going through Head First Design Patterns (just came in recently) and I was reading about the strategy pattern, and it occurred to me that it might be a great way to implement a common way of calculating taxes etc. on all of the particular objects I use at work, but I had a question about it.</p>
  
  <p>Here's what I was thinking:</p>
  
  <pre><code>public interface ITax
  {
      decimal ProvincialTaxRate { get; set; } // Yes, I'm Canadian :)
      decimal CalculateTax(decimal subtotal);
  }
  
  public SaskatchewanTax
  {
      public decimal ProvincialTaxRate { get; set; }
  
      public SaskatchewanTax()
      {
          ProvincialTaxRate = new decimal(0.05f);
      }
  
      public decimal CalculateTax(subtotal)
      {
          return ProvincialTaxRate * subtotal + FederalTaxRate * subtotal;
      }
  }
  
  public OntarioTax
  {
      public decimal ProvincialTaxRate { get; set; }
  
      public OntarioTax()
      {
          ProvincialTaxRate = new decimal(0.08f);
      }
  
      public decimal CalculateTax(decimal subtotal)
      {
          return ProvincialTaxRate * subtotal + FederalTaxRate * subtotal;
      }
  }
  </code></pre>
  
  <p>You may have noticed that there is no declaration of FederalTaxRate and that's what I wanted to ask. Where should that go? </p>
  
  <ul>
  <li>Passing it in to the constructor for each concrete ITax seems redundant and would allow for incorrect behaviour (all tax calculators must share the exact same federal tax rate).</li>
  <li>Likewise, creating a member of ITax would allow them to be inconsistent as well. </li>
  </ul>
  
  <p>Should all tax calculators inherit from some other class where it's defined statically as well as ITax?</p>
  
  <pre><code>public class TaxCalculator
  {
      public static decimal FederalTaxRate = new decimal(0.05f);
  }
  </code></pre>