Legacy Coderetreat: Episode 10 – Refactoring the Rule of Three – Code Cast

The book Facilitating Technical Events is for technical trainers, coaches, events organizers who want to have a good event flow and happy attendees.
Support independent publishing: Buy this e-book on Lulu.

Refactoring the Rule of Three – code cast

Blog post series

This blog post is part of a series about legacy coderetreat and legacy code techniques you can apply during your work. Please click to see more sessions about legacy code.

Code Cast

This is a code cast in Java.

When refactoring legacy code we need to make sure the structures we extract have a correct meaning. This is why The Rule of Three is very useful: extract to a new structure only when you find an identical duplication three times. Usually we do not have identical duplication, so in that case we need to make the duplication clear, check that it exists three times and only after that perform the extraction.

This code cast will show you also when it is not a good idea to extract a new variable, even if you see it duplicated many times. This is a mechanical kind of refactoring, but reasoning is very important even when we want to get fast by getting mechanical refactorings into our tool bag.

Read here more about this concept in my blog post.




Subscribe

If you want to receive an email when I write a new article, subscribe here:

Subscribe for new articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe for new articles