My Adventures in Coding

March 15, 2008

Refactoring to Patterns – Summary

Filed under: Refactoring — Brian @ 11:29 pm

While attending Joshua Kerievsky’s talk at SD WEST he went into a brief overview of a number of refactoring patterns. If you want to read about these patterns in detail (and you should!), you should get a copy of the book Refactoring to Patterns. However, to help peak your interest on the subject, here is a quick overview of a few of the patterns discussed at the talk.

The Three Basic Strategies used in Refactoring

  • Extract method
  • Extract class
  • Move Method

Piecemeal Refactoring Pattern

  • Divid and Conquer
  • Split problem in half
  • Work at solving smaller problems

Narrowed Change Pattern

  • Extract methods to determine where the change needs to be
  • So refactor 3 methods, not 50
  • Change only that area, make the change isolated to only a few places
  • Narrow the change down to a smaller number of change points

Gradual Cutover Refactoring

  • Move from A to B gradually
  • Start with 1,2,3 to 30
  • So the idea is you can ship to production with 10 of 30 pieces of code switched over while in a releasable state the entire time
  • This type of refactoring can be done along side other work without affecting the release schedule for other development work

Parallel Refactoring

  • Write the refactored code along side of the existing code
    • THEN decide later on how and when to finally cut over to the new code
  • This is a very conservative safe approach to refactoring.
  • It also gives management the ability to make the decision whether or not to cut over to the new code in a release
  • So if it is not tested properly by the time of the release, just don’t switch over, no need to roleback changes or take any other steps

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

Blog at

%d bloggers like this: