Refactoring Day 8 : Replace Inheritance with Delegation

All too often inheritance is used in the wrong scenarios. Inheritance should only be used in logical circumstances but it is often used for convenience purposes. I’ve seen this many times and it leads to complex inheritance hierarchies that don’t … Continue reading 

Posted in Uncategorized | 3 Comments

Refactoring Day 7 : Rename (method, class, parameter)

This refactoring I use most often and is one of the most useful refactoring. All too often we do not name methods/classes/parameters properly that leads to a misunderstanding as to what the method/class/parameter’s function is. When this occurs, assumptions are … Continue reading 

Posted in Uncategorized | Leave a comment

Refactoring Day 6 : Push Down Field

Opposite of the Pull Up Field refactoring is push down field. Again, this is a pretty straight forward refactoring without much description needed 1: public abstract class Task 2: { 3: protected string _resolution; 4: } 5:  6: public class … Continue reading 

Posted in Uncategorized | 2 Comments

Refactoring Day 5 : Pull Up Field

Today we look at a refactoring that is similar to the Pull Up method. Instead of a method, it is obviously done with a field instead! 1: public abstract class Account 2: { 3: } 4:  5: public class CheckingAccount … Continue reading 

Posted in Uncategorized | 3 Comments

Refactoring Day 4 : Push Down Method

Yesterday we looked at the pull up refactoring to move a method to a base class so mutiple derived classes can use a method. Today we look at the opposite. Here is the code before the refactoring: 1: public abstract … Continue reading 

Posted in Uncategorized | 6 Comments

Refactoring Day 3 : Pull Up Method

The Pull Up Method refactoring is the process of taking a method and “Pulling” it up in the inheritance chain. This is used when a method needs to be used by multiple implementers. 1: public abstract class Vehicle 2: { … Continue reading 

Posted in Uncategorized | 1 Comment

Refactoring Day 2 : Move Method

The refactoring today is pretty straightforward, although often overlooked and ignored as being a worthwhile refactoring. Move method does exactly what it sounds like, move a method to a better location. Let’s look at the following code before our refactoring: … Continue reading 

Posted in Uncategorized | 7 Comments

Refactoring Day 1 : Encapsulate Collection

In certain scenarios it is beneficial to not expose a full collection to consumers of a class. Some of these circumstances is when there is additional logic associated with adding/removing items from a collection. Because of this reason, it is … Continue reading 

Posted in Uncategorized | 18 Comments

31 Days of Refactoring

Refactoring is an integral part of continually improving your code while it moves forward through time. Without refactoring you accrue technical debt, forget what portions of code do and create code that is resistant to any form of testing. It … Continue reading 

Posted in Uncategorized | 43 Comments

‘Vice’ Testing

Refactoring to tests is no easy task. The largest problem that you run into is moving around code with no feedback as to whether you are breaking modules other than doing very high level user/functional testing directly against the UI. … Continue reading 

Posted in Uncategorized | 1 Comment