Hi
I have some PHP classes I am creating from XML config. What I would like to know is this:
Am I better off (from an object-oriented standpoint) having factory methods to create those classes from XML or passing in XML to the constructor to create the classes?
The factory approach has the advantage of separating construction from usage and more easily allowing alternative implementations but you then need to expose setters or pass in a whole bunch of objects to the constructor that constitute it's state.
A further subtlety of this is that passing in the XML allows you to create the objects top down and some lower down objects will need references to those objects above them. The second method will result in something that's more bottom up.
Or is there some more design pattern type way of going about this?
Thoughts?