Legacy Patterns Decision Tree

Way back when I first read the Michael Feathers book on “Working Effectively with Legacy Code”, I decided to write up a quick description of the patterns in the book for my coworkers to look up whenever they need them (basically, when trying to write unit tests for big, monolithic “legacy” classes).

These patterns are extremely intuitive once you’ve gone over them a few times. They’re really just obvious techniques for working around some constraints with as little risk and impact as possible. However, to reduce the learning curve, I created the decision tree below. I actually don’t think it’s very useful in practice, but creating it was a great way for ME to fully understand these patterns and their relationships. Now, I pass it on to you. My hope is that any of you developers out there may learn something from having a look at it. And, who knows, maybe there’s some insight here that can be used in my quixotic quest for the Legaciness metric.

Legacy Code Patterns Decision Tree

Legacy Code Patterns Decision Tree

Note that some of the leaf nodes recommend the use of mock objects, which are not part of the legacy code patterns themselves. I recommend the use of EasyMock, which is the library I’m using, but you can use whatever you prefer. If you can use fake objects, I find that to be generally easier than, and thus preferable to using mock objects.

Advertisements

4 Responses to Legacy Patterns Decision Tree

  1. Tim, thanks. That looks very interesting. When I wrote the book I felt bad that I couldn’t give much guidance about how to trade off the various dependency breaking techniques. I knew that I had preferences and I knew that many were situational, but I wasn’t sure if there were any overarching patterns.

    I’ll look closely at this. I like the decision tree approach.

  2. Timothy High says:

    Wow, thanks! It’s not perfect – it was just a first pass, but I hope you and others can find it useful. I have to say your book is on my list of top 10 books in software development, so it’s great to hear from you.

    Around the time I created this decision tree, I also embarked on a quest to unit test a 500+ line method as a way to try out and illustrate some of your patterns. I eventually gave up (I discovered there’s definitely a point where rewriting the whole thing from scratch is easier than trying to recover it – as indicated in the first graph in my “Causes of Decay” post), but there were some interesting insights before I did. I’ll try to post the series here when I get the chance.

  3. Leo Gomes says:

    I really like this decision tree. I used it many times while I was there with you guys. I still remember the day we sat together to try to test part of the infamous EOD report before a change I needed to do πŸ™‚

    Green-field projects are hard to find these days, and learning how to deal with legacy code is surely a mandatory skill – that’s what makes this book a must-have in every developer’s bookshelf. I remember I tried to trade one of Sakonnet’s copies with one of the books I wanted to leave in Brazil, but it didn’t work out. So, I bought my own copy as soon as I had an address here πŸ™‚

    BTW, do you mind if I share this tree in our internal wiki (with credits and a link, of course πŸ™‚ ?

  4. Timothy High says:

    Hey Leo,
    Great to hear from you! Hope things are going well for you on the continent.
    Of course you can put this on your wiki! But let’s say that this is a limited license that lets you use it under the following conditions:
    1) Any changes you make to it MUST be submitted back to the rest of the world.
    2) If you have any other observations about it, let us know!

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: