Piotr Gabryanczyk’s Blog

Java, Refactoring, AOP, Spring, DDD, TDD, etc.

  • Blogroll

    • I have joined Anti-IF Campaign

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.

Video

But reading emails full of code seems to be a bit boring, so this week I made a movie.
It shows the following refactorings:

  1. Extract Method
  2. Inline Variable/Replace Temp with Query
  3. Rename Variable

Show it to your team mates!
We can change the world together πŸ™‚

Disclaimer:

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 πŸ™‚

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: