Refactoring Course

I mentioned one day to Alistair that I want to improve my Eclipse refactoring skills and he pointed me to Refactoring to Patterns Interactive, an online course from Industrial Logic. I just went through the first pattern: Factory Method. The course requires that you have copies of Refactoring to Patterns and Design Patterns. The course is $150 US, but you can demo the Strategy pattern for free.

There are 17 patterns in total. For each pattern, the course has Read, Refactor, and Review sections.

The Read section recommends what to read in the two reference books, and also has some reading material online.

The next section, Refactor, is the fun section. Here, you download an Eclipse project with code to refactor. The code is packaged with passing tests to validate the correctness of your refactoring. Once you’ve completed your refactoring, there are clever reflection tests that will assess the quality of your refactoring. The Refactor section also contains a final solution that you can compare your solution against.

The final section, Review, has an online quiz that reinforces the concepts you’ve learned.

I really enjoyed this first pattern. The pattern is so simple and yet I learned quite a bit.

The approach to patterns taken by the course (and by Refactoring to Patterns) is that (the ease of) refactoring drives how one implements a pattern. When I was reading Head First Design Patterns (which is excellent), it was unclear to me what motivated specific design decisions when there are so many available. When I came across the State pattern in Refactoring to Patterns, the design decisions felt natural (and are quite different from those in Head First Design Patterns). They felt right, because the decisions aimed to implement the pattern with existing code as easy as possible if your unit of change is constrained to the simple set of standard refactorings (most of which can be automated with Eclipse).

One refactoring trick I learned is that refactoring code can be easier if you start with the client code calling the class you want to refactor rather than starting to refactor the class directly. This is evident in the first lesson in the online course, but is also frequently seen throughout Refactoring to Patterns. There are many similar non-intuitive indirections that speed up refactoring that are illustrated in Refactoring to Patterns.

I had set out to improve my Eclipse refactoring skills, and I was not disappointed. I didn’t know that, when you pullup a method in Eclipse, you can specify to delete similar methods in sibling classes. Also, I had never noticed that when you pullup a method there is a drop-down menu that allows you to declare the method as abstract in the parent class.

Not really part of the course, but I found it very clever how the course allows you to import an Eclipse project with a zip file. I also like how the Eclipse project uses Ant to generate a jar file for upload.

This course ties together refactoring, design patterns, the Eclipse refactoring tools, and a whole lot of fun. I highly recommend it.

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply