Advertisement Jump to content


This topic is now archived and is closed to further replies.


Factories or ct registration?

This topic is 6124 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ever had one of those designs in which you can go one of several different ways and still reach the same result? Each way of course has it''s own little nicities, but nothing profound? Here''s mine: I have an object XMLParser which creates a tree of type XMLEntity. This class is nothing more than an interface for several other classes, XMLTag, XMLData, XMLComment...(yes, I like XML). I would like to provide customisation for the parser by altering these classes and not the parser itself. I think this can be done one of two ways: 1. The XMLEntity could have a virtual static method used to contruct new objects of itself. This function would be "registered" via pointer in the Parser object for each type (Tag, Data, Comment...). In this way, one can register a different static constructor to modify the default behavior of that class. 2. Several virtual build...() functions are be part of XMLParser. These functions construct a new object of that type. You would subclass XMLParser to customize. Another thouoght is to use the factory pattern and pass new factories to the XMLParser, a bit cleaner than both but I would really like to see what everyone thinks being that this may be a Object-oriented alternative to Expat. -Solstice "...I was given three choices, the earth, the stars, or..."

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!