title: design patterns for currency conversion?
body: <p>I was wondering if we could apply design patterns to writing code for currency conversion, and if yes then what would they be? The assumption is that conversion rates are static and we can hard-code them.</p>
  
  <p>I thought about using 'state pattern' where every state represents a specific currency and has formulas encapsulated into corresponding methods for conversion, e.g. 'toDollars()',  'toPounds()' etc.</p>
  
  <p>Another possibility (not sure if it's a design pattern) is using function objects that convert from a specific currency to another, and storing them as values in a 2-level Hashtable where the first level key is 'from' currency and the second level key is 'to' currency.</p>
  
  <p>Are there any other design patterns to apply to this problem? The problem at its most abstract level is that we have 'm' entities and they are all inter-convertible based on some specific rules. Examples are converting time zone values in to each other; calendar dates from different calendar types (Gregorian/Chinese) etc. into each other.</p>
  
  <p>Thanks and regards!</p>