Here’s another architectural type question... I’m building a module that’s using the Factory pattern (thanks to Shaun’s suggestions)... it dynamically loads other classes as needed.
I have a bit of a mess right now because some of my classes get a reference to the parent object and some do not:
class Child {
var $ParentObject;
__construct(ParentObject &$ParentObject) {
$this->ParentObject =& $ParentObject;
}
}
// vs. a vanilla class:
class StandAlone {
__construct() { }
}
What that means is that my code that loads the new classes has to be configured as to what type of file it is loading (e.g. class name, whether or not it gets a reference of the parent, etc.).
Am I missing the point of the Factory Pattern? Or should I just suck it up that my loader has to be able to deal with different types of classes? Originally, I had refrained from passing in the ParentObject reference because some of the classes simply don’t need that reference... they’re fine on their own.
Thoughts? Am I just blowing my own mind?