Monthly Archives: August 2009

31 Days of Refactoring Series complete!

Well, we have come to the end of the series. I hope everyone has found some value in the series. Some examples were extremely contrived and maybe not all that useful but hopefully someone can use them at some point. … Continue reading 

Posted in Uncategorized | 6 Comments

Refactoring Day 31 : Replace conditional with Polymorphism

The last day of refactoring comes from Fowlers refactoring catalog and can be found here. This shows one of the foundations of Object Oriented Programming which is Polymorphism. The concept here is that in instances where you are doing checks … Continue reading 

Posted in Uncategorized | 12 Comments

Refactoring Day 30 : Return ASAP

This topic actually came up during the Remove Arrowhead Antipattern refactoring. The refactoring introduces this as a side effect to remove the arrowhead. To eliminate the arrowhead you return as soon as possible. 1: public class Order 2: { 3: … Continue reading 

Posted in Uncategorized | 10 Comments

Refactoring Day 29 : Remove Middle Man

Today’s refactoring comes from Fowler’s refactoring catalog and can be found here. Sometimes in code you may have a set of “Phantom” or “Ghost” classes. Fowler calls these “Middle Men”. Middle Men classes simply take calls and forward them on … Continue reading 

Posted in Uncategorized | Leave a comment

Refactoring Day 28 : Rename boolean method

Today’s refactoring doesn’t necessarily come from Fowlers refactoring catalog. If anyone knows where this “refactoring” actually comes from, please let me know. Granted, this could be viewed as not being a refactoring as the methods are actually changing, but this … Continue reading 

Posted in Uncategorized | 3 Comments

Refactoring Day 27 : Remove God Classes

Often with legacy code bases I will often come across classes that are clear SRP violations. Often these classes will be suffixed with either “Utils” or “Manager”. Sometimes they don’t have this indication and are just classes with multiple grouped … Continue reading 

Posted in Uncategorized | 4 Comments

Refactoring Day 26 : Remove Double Negative

Today’s refactoring comes from Fowler’s refactoring catalog and can be found here. This refactoring is pretty simple to implement although I find it in many codebases that severely hurts readability and almost always conveys incorrect intent. This type of code … Continue reading 

Posted in Uncategorized | 13 Comments

Refactoring Day 25 : Introduce Design By Contract checks

Design By Contract or DBC defines that methods should have defined input and output verifications. Therefore, you can be sure you are always working with a usable set of data in all methods and everything is behaving as expected. If … Continue reading 

Posted in Uncategorized | 5 Comments

Refactoring Day 24 : Remove Arrowhead Antipattern

Today’s refactoring is based on the c2 wiki entry and can be found here. Los Techies own Chris Missal also did a very informative post on the antipattern that you can find here. Simply put, the arrowhead antipattern is when … Continue reading 

Posted in Uncategorized | 7 Comments

Refactoring Day 23 : Introduce Parameter Object

This refactoring comes from Fowler’s refactoring catalog and can be found here Sometimes when working with a method that needs several parameters it becomes difficult to read the method signature because of five or more parameters being passed to the … Continue reading 

Posted in Uncategorized | 3 Comments