Friday School of Refactoring – Extract Method – video
Posted by Piotr Gabryanczyk on December 6, 2006
People still don’t use refactoring!
Some time ago I realized how many developers still don’t use simple refactorings like Extract Method or Replace Temp with Query etc. Many of them don’t know how excellent the development tools are these days. Simple one-click/keystroke operation can make their code much prettier and simpler.
I even heared once the opinion that “tools can not be trusted” as they can break the code while refactoring.
I don’t think it is the case especially with IntelliJ and Eclipse. These editors are quite smart and if used well can almost write the code for you 🙂 I know, I know I went too far…
Friday school of refactoring
I decided that I have to do something to change it. I started posting a weekly refactoring guide to my team-mates. Every week I pick some example from our system and make it simpler, prettier, easier to maintain – I refactor it. You could see one of the examples in my post Refactoring – conditionals.
But reading emails full of code seems to be a bit boring, so this week I made a movie.
It shows the following refactorings:
- Extract Method
- Inline Variable/Replace Temp with Query
- Rename Variable
Show it to your team mates!
We can change the world together 🙂
I know that movie has a bug – extract method takes one line at the top too much…
I am too lazy to fix it… and not too many people spotted it 🙂