Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7506709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:20:11+00:00 2026-05-29T22:20:11+00:00

First of all, this is a design question rather than an issue: I have

  • 0

First of all, this is a design question rather than an issue:

I have an existing application written in C++.

The structure is as following:

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();
}

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:

<?xml version="1.0"?>
<Steps>
   <Step id="step1">
      <param method="setValue" variable="v" value="1" />
   </Step>
   <Step id="step2">
      <param method="setValue" variable="v" value="2" />
   </Step>
</Steps>

And then I will add a class to parse the xml file:

class XmlParser
{
public:
XmlParser();
int parse(string xmlFile, string paramValue);
}

then I think I will change the main class only:

void main()
{
    Step1 step1();
    Step2 step2();

    XmlParser xmlParser();

    step1.setValue(xmlParser.parse(,));
    step2.setValue(xmlParser.parse(,));

    step1.process();
    step2.process();
}

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?

I would like to know your opinions.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:20:12+00:00Added an answer on May 29, 2026 at 10:20 pm

    I have already faced this problem and I have done something similar. I think it’s the most reasonable solution. For creation and setting of an instance of your processing classes (Steps, in your example) should be responsible your main subroutine/class.

    One problem is parsing XML, you might change your current source code into the mess. To prevent that, you should create some class “Configuration”, that is responsible for parsing, error handling and default values of your settings.

    Simple example of Configuration class interface:

    class Configuration {
    public:
        // basic configuration
        Configuration();
        // parsing, DTD validation
        void parse(const std::string& filename);
        // get some value
        // you can provide default value if necessary
        // or you can have some more robust accessing methods
        // depends on complexity of your settings
        int getSomeValue(int default);
        ...
    };
    

    Main subroutine is not filled with parsing stuff:

    void main()
    {
        Configuration config;
        config.parse("path/to/config.xml");
    
        Step1 step1();
        Step2 step2();
    
        int someValue = config.getValue(5);
        step1.setSomeValue(someValue);
        ...
    
        step1.process();
        step2.process();
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A noob question. I'm putting together my first database and have the following design
This is a high level/design type question rather than anything specific. In this game
First of all this is my markup: <div class=first></div> <div class=second></div> <div class=second></div> <div
first of all this is my third question about web services here and i
First of all: This question is not directly programming related. However, the problem only
Well, first of all sorry about this question it must be pretty straight forward
First of all there is probably a question like this already but i couldn't
First up, i realize this application has some design issues and while rewriting a
First of all, i'm a Graphic designer so please ignore if this programming question
This question was asked already here , but rather than answering the specific question,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.