Published on 20 September 2013 by @mathiasverraes
There are no slides for this presentation, it’s all live demoing. The code is on GitHub. I prerecorded a screencast. You’ll notice I haven’t managed to cram in everything I hoped to show, when I wrote the abstract. If plenty of people are interested, I’ll record more videos of refactoring techniques.
The title refers to a quote from Robert C. Martin about applying Extract Method and other refactors until every element in your system has just one responsibility:
Perhaps you think this is taking things too far. I used to think so too. But after programming for over 40+ years, I’m beginning to come to the conclusion that this level of extraction is not taking things too far at all. In fact, to me, it looks just about right. So, my advice: Extract till you just can’t extract any more. Extract till you drop.
I owe a lot to Sandro Mancuso, who did a similar, much more advanced presentation in Java, which greatly inspired me to try this in PHP.
Many of the ideas here are
stolen borrowed from him.
We’ve all seen them: applications out of control. Under the pressure of deadlines and endless change requests, with the weight of years of legacy, the code has become unmaintainable. Adding features is a slow hit and miss process. You know something needs to be done, but nobody knows how. To change the code safely, you need tests, but to make it testable, you need to change it. Rebuilding the system from scratch is not an option.
With the right tools, techniques, and mindset, any codebase can be brought under test, and be refactored towards a better architecture. All without affecting the behavior of the system, and allowing the business to continue.
This presentation is not for the weak of heart. We’ll skip the theory and dive straight into the spaghetti code. We’ll wrestle in the mud, and we’ll tame the beast, whether it wants to or not. It’s live coding, and it may fail. But it will change how you approach legacy code forever.Follow @mathiasverraes on Twitter.
This work by Mathias Verraes is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License.