I have an external excel file which contains a list of different parameter values needed in order to run an application. One of the parameters in the excel file is, numberofcustomers
. I read this at the beginning of my program into an object, say, globalconstant
object, gcs
. The class globalconstant
has a private data member int Numberofcustomers;
Whenever I have to use this parameter in my program, I access this via a public member function of the class defined thus:
int numberofcustomers() const {return Numberofcustomers;}
For instance, if I have to loop through the number of customers, I have:
for(int i = 0, sz = gcs.numberofcustomers(); i < sz; i++){...}
Thus, the compiled and built executable has no idea what numberofcustomers
could be.
As opposed to this, another design could be to explicitly define:
static const int numberofcustomers = 100;
in a header file and recompile/rebuild the entire project. This way, I can completely do away with the need of the external excel settings file.
Are there any compiler optimizations I am missing out on by having the first design (store parameter values in excel file that is read in during run time) as opposed to the second design (store parameter values in the source code itself)? It appears to me that the second design should benefit from benefits since it knows how many number of customers are there in the problem before run time itself.
The number of different parameters I have are 15 to 20 or so. The benefit of the first design is that it is much easier to manage the parameters by opening just the excel file and modifying it. It also saves me from the hassle of recompiling and rebuilding my project.