I am currently writing a plugin to a CAD style software. The plugin does calculations based on data read from the CAD model and a lot of table lookups (think printed tables in a calculation guide). I inherited this plugin and the current solution defines a class Constant
which has a bunch of static struct members and two-dimensional arrays. These arrays are then indexed by enum values at runtime to find the appropriate data.
I'm not too happy with the sollution, as the representation in the Constant
class is kind of hard to read - the enum values used when retrieving data are of course not visible when editing the data (allthough that only ever happens manually and very seldomly).
I'd prefer not to bundle a DB (and engine) with a small plugin, but would like similar semantics, for instance using LINQ to select values where some fields match etc.
What is your preferred solution to this problem?
- do you use a bunch of XML files and parse them at runtime?
- do you use a templating engine (t4?) to generate classes from XML files at compile time?
- do you store XML versions of datasets in the resources (read 'em in at runtime, LINQ to dataset...)
- would you just keep the
Constants
class, maybe add some documentation to the members (don't get me started about legacy code with no comments whatsoever...)