I'm currently working on a program, a scientific simulation, with the following structure (first level - logical grouping, second level - implemented classes, third level - implemented subclasses):
- Input Data
- Sample
- Parameter(abstract base class, declaring virtual functions)- ParModel1
- ParModel2
- ...
 
 
- Physical Models
- Model(abstract base class, declaring virtual functions)- Model1
- Model2
- ...
 
 
- Simulation
- Simulation
 
The Model subclasses (e.g. ModelX) define certain algorithms in a virtual Calculation(int x) function, representative for the physical model X to be described. The parameters to be used in this calculation will be provided by a Sample object and a respective ParModelX object.
The Simulation class knows how to deal with a Model in general and will eventually perform the calculation for a given x (by calling the public Calculation(int x) function)... in a biiig for-loop.
We approach the actual question... During each iteration, the calculation defined by the ModelX will be performed and thus various parameters of the Sample and ParModelX objects need to be accessed.
Since the Simulation class only triggers a provided public calculation function of Model, it's only Sample and Parameter which both have to communicate with Model.
Should I...
- Have the members declared privateand provideget-functions? (I read that heavy dependence on getters/setters can be a sign of flawed design. Could too many get function calls be a problem in an ampleforloop or is it "bad style" respectively?)
- Have the members declared 'public' but const(they won't need to change!) so that 'Model' can access them without a function call? (Doesn't look like good style to me...)
- Let the Modelconstructor extract the parameters from givenSampleandParameterobjects and store them in its own members for quick access (this would make theParameterclass redundant!)
- friend- Sampleand- Parameter(etc.) with the according- Models
- other options...?
I'm concerned about the speed (even if it may not be important in my particular calculation, I want to know what would be good programming style!) and the structure of my program. I, for instance, don't want the models to be mixed with the simulation/calculating process. The separation of input data and models seemed good to me, because of the possibility to have many parameter sets for one model...
 
     
    