all
I'm facing a design problem. I want to separate building objects with a builder pattern, but the problem is that objects have to be built from configuration file.
So far i have decided that all objects, created from configuration, will be stored in DataContext class (container for all objects), because these objects states will be updated from a transmission (so it's easier to have them in one place).
I'm using external library for reading from XML file - and my question is how to hide it - is it better to inject it to concreteBuilder class? I have to notice that builder class will have to create lots of objects, and at the end - connect them between each other.
Base class could look like that: /* * IDataContextBuilder * base class for building data context object * and sub obejcts / class IDataContextBuilder { public: / * GetResult() * returns result of building process */ virtual DataContext * GetResult () = 0; /* * Virtual destructor */ virtual ~IDataContextBuilder() { } };
class ConcreteDataContextBuilder { public: ConcreteDataContextBuilder(pugi::xml_node & rootNode); DataContext * GetResult (); }
How to implement it correctly? What could be better pattern to build classes from configuration files?
Aucun commentaire:
Enregistrer un commentaire