
Working effectively with legacy code
by Michael C. Feathers · first published 2004
315mentions
186recommended by
234HN commenters
2008–2026first – last mentioned
79% recommend20% neutral1% critical
Why HN recommends it
Practical techniques for getting tests around untested existing code, such as finding seams and breaking dependencies, so you can refactor safely; suits engineers inheriting tangled, tightly coupled codebases.
Summarised by Claude from recommending comments
Affiliate links. As an Amazon Associate I earn from qualifying purchases.








…the questioner is working in JavaScript, Martin Fowler came out with a second edition of Refactoring with JS code that might be useful. I've never read the first edition (in Java) but Michael Feathers' Working Effectively With Legacy Code is a frequent recommendation of mine. Its main goal is to get your mess under test, ideally tests that help you understand the system as well as improve its quality. It's organized as a set of questions…
on “Ask HN: How to be productive with big existing code base” ↗…know better; they may have inherited a mess too, and they may have been under pressure to deliver quickly at any cost--or maybe they just don't know any better, but want to improve. Read these books: _Working Effectively with Legacy Code_ by Michael Feathers _Refactoring: Improving the Design of Existing Code_ by Martin Fowler _Clean Code_ by Uncle Bob These are invaluable resources. There are many others, but these three are particularly…
on “Ask HN: Codebase at my work is a complete mess, what should I do?” ↗…Domain Driven Design * Design Patterns: Elements of Reusable Object-Oriented Software * Kent Beck - Extreme Programming Explained * Kent Beck - Planning Extreme Programming * Michael C. Feathers - Working Effectively with Legacy Code * Daniel Kahneman - Thinking, Fast and Slow [EDIT] Correct the author for legacy code
on “Ask HN: What books had the greatest effect on how you structure your code?” ↗There's a book called "Working Effectively with Legacy Code" by Michael C. Feathers which I heartily recommend. I got it a while back when working on a similar sounding codebase and it was very useful. It's got chapter headings like "My Application Has No Structure"…
on “Ask HN: Codebase at my work is a complete mess, what should I do?” ↗I'll open by saying I've only ever had bad experiences with complete re-writes and these experiences have impacted my aversion to them. "[Working Effectively with Legacy Code]" by Michael Feathers really helped me get through a situation like this. My recommendation is not to try to understand the code per se, but understand the business that the code was being used in/by.…
on “Ask HN: Have you ever inherited a codebase nobody on the team could understand?” ↗…AstroGrep http://astrogrep.sourceforge.net/ to quickly search and jump around in the code or in any system I use VS Code for a similar functionality. Also learn to use command line find/grep. The book "Working Effectively with Legacy Code" also helped me be more comfortable navigating and changing large code bases, in a long term view I recommend this book to every developer https://www.amazon.co.uk/Working-Effectively-Legacy-Michael-...…
on “Ask HN: How do you learn new libraries without much documentation?” ↗…understand that it does. I have been dabbling in queueing theory before this book, but the focus this book put on practical applications really made me understand it on a deeper level than before. = Working Effectively with Legacy Code by Michael Feathers. I didn't originally want to put this one in this list because it's so predictable, but I can't not. I keep coming back to it and re-reading portions of it every time I have to deal…
on “Ask HN: Name 3-5 books that had the most impact on your career and knowledge?” ↗See also "Working Effectively with Legacy Code" book by Michael Feathers, IMHO _the_ book on this topic. http://my.safaribooksonline.com/book/software-engineering-an...
on “Cleaning bad code” ↗Michael Feathers' "Working Effectively with Legacy Code" is a great book that I would recommend for such situations.
on “What are your strategies for diving into a large, complex codebase?” ↗…and add value to the conversation. Nice snark there. Feel free to keep it to yourself. To add actual value to the conversation (as opposed to your contribution), I can very much recommend the book "Working Effectively with Legacy Code"[1] for how to handle unit-testing in the scenario of existing "legacy" code-bases. It's full of useful tips and methods to get testing in place "anywhere" and has a pragmatical (as opposed religious)…
on “How we took our tests from 100 seconds to 100ms” ↗…in the process of writing tests, which can be a tragedy when dealing with a legacy codebase that was written with insufficient testing but is otherwise well-designed. Have you read Michael Feathers' Working Effectively with Legacy Code? [0] In his definition of legacy code it is any such code that has no test coverage. It's a black box. There are errors in it somewhere. It works for some inputs. However you cannot quantify either of…
on “TDD did not live up to expectations” ↗…you're peddling software design advice, take some time to make (or find) a realistic example so I don't have to imagine so hard. Even if it's in a toy-problem type of scenario the code can be realistic. Working Effectively With Legacy Code has spoiled me by setting such a higher standard than most peddlers, since it actually presents real code (sometimes 3 pages of it at once) in real languages (Java and C++) using styles and highlighting…
on “My favorite principle for code quality” ↗…Beck. It is probably not the best book on TDD, but it will give you the basics without confusing you. If you are working with legacy systems and don't know how to TDD with those legacy systems, read: Working Effectively With Legacy Code by Michael Feathers. It is a very, very difficult book. Learn it all. You may hate TDD. Many people do, but using it will make you a better programmer. Personally, I don't think it's bad if you…
on “Ask HN: I have a mental block designing software. Time to quit?” ↗Michael Feathers' Working Effectively with Legacy Code is the authority on this, I think.
on “How to Read Other People's Code -- And Why” ↗Michael Feathers's _Working Effectively with Legacy Code_ is entirely about dealing with this sort of code, especially on carefully retrofitting tests so you can safely do deeper restructuring.
on “Every app has a scary basement—dark old mysterious code vital to its operation” ↗