From: Marko v. D. <Mar...@cs...> - 2002-11-25 19:50:43
|
I've been working on a system of quantities and units. Initially I implemented each unit and quantity in a separate class, but now I'm implementing derived quantities, the amount of classes is exploding. I want to implement at least all quantities and units on http://physics.nist.gov/cuu/Units/units.html. All classes are singletons, but even if they are not implemented that way, the implementation will always try to use the same objects instead of creating new ones. I was planning to create a class SI (or something like that) anyway for convenience (not having to import zillions of classes), so I'm wondering if instead of only providing final static constants in that class, I should also put the instantiation of different units in there, and get rid of the subclasses. That would mean that base quantities (and units) would have to be singletons in order to work since the only useful test would be == when they are all instances of the same class (not that I have any problem with that since there is no use for more than 1 instance of a certain base quantity). I can't really find a good reason now for creating a separate class for every different quantity/unit. It seemed like a good idea at first, but now ... In other words, I want your $0.02 Marko -- Jutil.org - Programming as you know it is over http://org-jutil.sourceforge.net |