Database has multiple injection types (mysql, postgres, etc)
Router has multiple implementations (simple, etc)
Session has multiple implementations as well (File, Shmop, MySQL, Postgres, etc)
As it currently stands, each is instantiated and injected in a concrete fashion, that is, something like this:
Code: Select all
$database = new Database(new DatabaseMySQL('localhost', etc));Although stratgey is about offering different algorithms, not entire implementations, so I wonder if maybe what I am looking at is a factory or sorts?
Subclassing is not what I am looking to achieve here, rather just to isolate the creation of one of any number of driver/implementation objects and inject that into the adapter object. The creation of the driver class is based on some algorithm, not explicitly stated by the caller, such as I would suspect is the case with a factory|abstract factory method.http://en.wikipedia.org/wiki/Factory_method_pattern wrote:The essence of the Factory Pattern is to "Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses."
Builder pattern sounds a little overly complex, building a composite and returning that instance as opposed to just creating a single class based on a few settings provided.
Any comments, suggestions?
Cheers,
Alex