I want to build three sites in PHP. I'm doing this as slowly, thoughtfully and carefully as I can, to learn as much about things like OOP and software architecture as possible.
From past experience I already know there will be a time when I will be glad to have logging functionality. I probably want to have different types of logs, by which I mean that in a
.ini file, I want to be able to specify if logging should go to a text file (perhaps a tab-delimited or CSV file), a database table, or smoke signals. I'd have (let's say) a Logger class, which would define, for example, an AddEntry() method. For each log type, I'd make a subclass that knows how to log to CSV file, write to a database or kindle a fire, respectively.
Since I know I will want to have an instance of a subclass, but I won't know which subclass to instantiate until runtime, I figured I'd use the Factory Method pattern. However, When I look at its Wikipedia article I'm noticing that the
ConcreteCreator have a different type than the
Product, if I'm reading the UML correctly. My question comes down to this:
I want to have the factory method as a static method of the Logger base class itself. If I do that, am I setting myself up for a trap that I'm not seeing yet? Is there a reason why the
ConcreteCreator should be of a different type than the