Update: Now on github
These are the slides from my presentation to the GTA PHP Meetup Group last night. Thanks to everyone who attended for your questions, and for hanging on with me while I debugged some unexpected issues while refactoring. I will post again when I have the source up on git if you want to try your own hand the same changes, or your own changes.
I’m not sure if this was your intention but the impression that “good engineering” principles make code complicated and therefore should be applied as little as possible seems a little short sighted.
There’s definitely such thing as unnecessarily complicated (factory pattern with only two concrete instances and very little chance of future additions / changes) but I don’t know if I’d advise people to not improve code or implement complicated engineering principles until code smells. Proper planning and foresight you should be able to implement good engineering prior to code smelling and the more practice one gets with good engineering the less complicated they become.
IMHO Colin (hutchic)
IMHO you’re fixing a problem that isn’t there and adding complexity for no reason if there was no code smell to begin with.
This is in line with agile practices like TDD which advocates not writing code until a test demands it and the overall principal of “You ain’t gonna need it”.
The trouble with proper planning and foresight is that your plan may be off target, and the only way to know for sure is to take the bullet of getting it wrong once before applying SRP – or any other principal that adds complexity.
On the other hand, if the SRP solution is less complex to begin with then I’d agree with you to go for it right away.