I'm currently in the process of modelling a generic form of RNA and RNA transcription and I'm having difficulty finding a proper OO modeling of this area.Human RNA has 4 types of Nucleotides (A, G, U, and C).  An RNA strand is just a string of these 4 types.  eg, AAGACAUUCUA...What I'm trying to model is more generic in the sense that I want to be able to decide the number of Nucleotide types at runtime.  So, my object model needs to be able to represent an arbitrary number Nucleotide types.Initially, I thought I'd just have a Nucleotide class which had a int TypeId member.  This way, I could have a sequence of Nucleotide instances of arbitrary types... but this doesn't feel right.I'm not a huge fan of storing type in a variable.  I'm also not comfortable with what is essentially definition information being set on every instance (instead of being defined in the a class).So, how do I get around this?  Here's what I've come up with so far:On a previous project, we would have Singleton objects which represented another object's type.  The other object would simply reference the singleton and that was it.  It prevented us from having multiple instantiations of the definition of our types.  Not too great IMO.I remember Entity Framework generating Dynamic Proxies at runtime.  I could so something similar.  I could have a NucleotideBase base class and, at runtime, define derived classes.  I believe this is possible through reflection.  I'm not sure what the performance impact is with this approach, but I would assume it's all just one-time overhead when defining the classes.Are there better, more OO, approaches?
How to model an arbitrary number of types
object oriented;modeling
If a nucleotide has no significant behavior, and if its type information can be represented compactly (for example, a single character), then it doesn't deserve a separate class at all.  Simply represent each nucleotide as a character (or whatever).If, however, a nucleotide has behavior, then I would model this with singletons, one instance per nucleotide type.Since there is no difference in behavior in nucleotides, they are simple value objects.  A nucleotide instance should be immutable, so that all nucleotides of a given type can be represented by a single instance.I would like to use the nucleotide's symbol as its type; this would be the sole instance variable of a Nucleotide.A nucleotide factory can keep track of the singleton instances of nucleotide, creating a new instance when a new nucleotide type is asked for, or returning an existing instance otherwise.  Depending upon the language, it may be convenient for this factory to be implemented in static methods of the nucleotide class.