I'm working on a project where I model genetics. I'm using classes to mimic multi-dimensional vectors. Basically I'll have a population object which contains a vector of individuals. The individual objects will each in turn contain a vector of genes. These genes will each in turn contain a vector of loci and on down to alleles. When I initialize a population that means I currently feed a bunch of variables to the constructor (number of individuals, number of genes ect...) then keep passing these variables on down from constructor to constructor to constructor. I pass them down as a reference to an array created in main() but is there a more elegant way to do this?
One alternative idea I had was to use multi-level inheritance. That way, for example, a gene object will have access to a public getter function in the base population class that can tell it how many loci it needs to contain during construction. My concern here is bloating. I'm worried about the size of, say a gene object. Will it be larger because it inherits from all the ancestor classes?
Another idea might be to make all the levels derive from a populationStatistics class that just contains all the constructor variables.
Can you guys give me advice on the cleanest way to implement this kind of pattern? Basically I would like avoid passing all these variables from class to class during construction. Or, if that's the best way, then I can stop trawling for alternatives.