Thursday, 10 November 2011

Working Effectively with Legacy Code

by Michael Feathers

ISBN-13: 978-0131177055

This is my second read through of Working Effectively with Legacy Code. I don’t usually read books twice, but it was being used as the material for an ACCU Mentored Developers project I was running.

Working Effectively with Legacy Code is almost as relevant now as when I read it in 2007. The only real thing that dates it are some of the links to pages that have moved on and some of the techniques which were new then, but are far more widely understood now. A credit to the book in a lot of ways.

Both times that I read it I felt that it didn’t teach me much that I hadn’t already learned during my career. I have been exceptionally fortunate to have worked with or been associated with some of the best developers in the world, so it was inevitable that I would pick this stuff up. Many developers are not so fortunate and that is why this book remains in my top ten.

All of that aside, this book contains surprisingly practical advice. I remember seeing Michael Feathers presenting at an ACCU conference and the room, including myself, being up in arms about using inheritance to mock out the methods of a class under test. Now I’ve read the book I understand that is just a first step to get the class under test before you refactor.

Singleton is a pattern that comes up again and again in all sorts of books (I’m reading a UML book at the moment and it’s even there!). One of the problems with singleton is that it is difficult to test. Feathers shows how you can get a singleton in existing code under test before you refactor it out. This is not the same as advocating singletons.

Feathers describes techniques for getting code under test that I had considered in the past and dismissed as far too complicated to be useful, but he makes them simple and straightforward. I could go on and on with example after example but the bottom line is that even if you’ve been fortunate in your career, you should read this book to get even the smallest bits that you haven’t considered.

2 comments:

  1. I've often thought I should write a book, "Working, effectively, with legacy code"

    ReplyDelete
  2. Or even "Working. (Effectively with legacy code)"

    ReplyDelete