I've recently completed work on a molecular/protein viewer for a computer graphics class. Atoms are obviously a very important part of such a program. Currently, I have a big enum that contains each Element (Hydrogen, Helium, etc). Each Element has associated information such as color, radius, etc. I'm using an extension class so I can write:
float r = Element.Neon.Radius(); I also need to be able to get the corresponding enum from it's symbol. I stuck that method in the extension class which is a bit messy:
Element carbon = ElementExtensions.FromAbbreviation("C"); I want to associate a lot more data with particular Element entries but I'm not sure if this is a good design or not. Currently each set of associated data requires a Dictionary to grab the associated data. Perhaps I could use a Dictionar?
If I went with an Element class I'd need to make sure there's only even one instance of hydrogen, one of helium, etc. I like how System.Drawing.Color is designed but I don't think that's exactly what I need (you'd never have to look up associated data for ForestGreen for example).
What's the best way to support a large but well-defined and finite number of specific instances?