Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel-eecis!news.mathworks.com!newsfeed.internetmci.com!info.ucla.edu!psgrain!qiclab.scn.rain.com!gemstone.com!servio!servio!aland
From: aland@servio.slc.com (Alan Darlington)
Subject: Re: Modeling physical units
Message-ID: <1996Jul22.182730.27291@gemstone.com>
Sender: news@gemstone.com (USENET News)
Nntp-Posting-Host: servio
Organization: GemStone Systems, Inc., Beaverton OR, USA
References: <31ED7E93.1722@ab.com> <4sm4hf$kbg@news00.btx.dtag.de>
Date: Mon, 22 Jul 1996 18:27:30 GMT
Lines: 37

Thilo.KHK@t-online.de (Thilo Schmid) writes:
<snip> 
> There is a similar problem in comercial applications, e.g. foreign 
> currencies in amounts. You have basically two choices:
> 1. Compose magnitude and dimension in one class, or
> 2. Use a seperate class for each dimension.
> 
> Practice has shown, that the latter is more convenient if you like to use 
> instances of these classes together with mechanisms for magnitudes (e.g. 
> build an Interval etc.). The former is more convenient, if dimensions 
> might change for certain values, which is not necessary in case of 
> physical dimensions (they usually do not change and conversion implies 
> the creation of new instances).
> 
> Techniques like Double Dispatching can be implemented more easily using 
> seperate classes. Double Dispatiching is conventient for generic 
> operators like "*" for multiplying values with different dimensions.

Ward Cunningham designed a multi-currency system while working on a
portfolio management application at a former employer (1990-1). He had
separate classes for each currency (in the prototype, at least) with
lazy rate tables and currency vectors for currency conversions.  It
was a bit messy, as we had to be able to convert a given amount to any
other currency as of any arbitrary date - with currency exchange rates
changing daily!

We were leaning toward using specific classes for the common currencies
(U.S., German, Japanese, etc.) and a generic class for the less common
ones.  This would improve performance for common currencies and also
allow our customers to create their own currencies by specifying
parameters for the generic currency.

Unfortunately we never got far enough to actually try it out...  :-(

  Cheers,
  Alan
    (standard disclaimer)
