Note that there are some explanatory texts on larger screens.

plurals
  1. POconfiguring an existing application written in C++
    primarykey
    data
    text
    <p>First of all, this is a design question rather than an issue:</p> <p>I have an existing application written in C++.</p> <p>The structure is as following:</p> <pre><code>class Step1 { public: Step1(); void process(); void setValue(int v); // is to change the value private: int value; } class Step2 { public: Step2(); void process(); void setValue(int v); // is to change the value private: int value; } void main() { Step1 step1(); Step2 step2(); step1.setValue(1); step2.setValue(2); step1.process(); step2.process(); } </code></pre> <p>I am now allowed to change the current architecture but it is required to configure all of the steps from outside. I am proposing to create an xml file holding the configuration settings:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;Steps&gt; &lt;Step id="step1"&gt; &lt;param method="setValue" variable="v" value="1" /&gt; &lt;/Step&gt; &lt;Step id="step2"&gt; &lt;param method="setValue" variable="v" value="2" /&gt; &lt;/Step&gt; &lt;/Steps&gt; </code></pre> <p>And then I will add a class to parse the xml file:</p> <p>class XmlParser { public: XmlParser(); int parse(string xmlFile, string paramValue); }</p> <p>then I think I will change the main class only:</p> <pre><code>void main() { Step1 step1(); Step2 step2(); XmlParser xmlParser(); step1.setValue(xmlParser.parse(,)); step2.setValue(xmlParser.parse(,)); step1.process(); step2.process(); } </code></pre> <p>I have more than 20 steps and there are about 10 methods to be configured in every step. Is it a good idea to change the architecture in this way that the XmlParser class will parse the xml file and pass the values to the set methods of the steps. Or is there a better way to do this? </p> <p>I would like to know your opinions.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload