Working Effectively with Legacy Code

Working Effectively with Legacy Code

  • Downloads:3200
  • Type:Epub+TxT+PDF+Mobi
  • Create Date:2021-03-13 03:18:27
  • Update Date:2025-09-07
  • Status:finish
  • Author:Michael C. Feathers
  • ISBN:0131177052
  • Environment:PC/Android/iPhone/iPad/Kindle

Summary

Get more out of your legacy systems, more performance, functionality, reliability, and manageability。Is your code easy to change? Can you get nearly instantaneous feedback when you do change it? Do you understand it? If the answer to any of these questions is no, you have legacy code, and it is draining time and money away from your development efforts。

In this book, Michael Feathers offers start-to-finish strategies for working more effectively with large, untested legacy code bases。 This book draws on material Michael created for his renowned Object Mentor seminars, techniques Michael has used in mentoring to help hundreds of developers, technical managers, and testers bring their legacy systems under control。

The topics covered include:

Understanding the mechanics of software change, adding features, fixing bugs, improving design, optimizing performance
Getting legacy code into a test harness
Writing tests that protect you against introducing new problems
Techniques that can be used with any language or platform, with examples in Java, C++, C, and C#
Accurately identifying where code changes need to be made
Coping with legacy systems that aren't object-oriented
Handling applications that don't seem to have any structure

This book also includes a catalog of twenty-four dependency-breaking techniques that help you work with program elements in isolation and make safer changes。

Download

Reviews

Kai Wolf

Great read on (disgusting and interesting) tricks and tips on how to manage legacy code, adding features, making changes without breaking stuff。

Dmytro Chasovskyi

Great book! With a list of practical suggestions。 Sometimes during reading, I had to stop and jump to my code as some improvement ideas came from the book。

Adolfo

100% recommend this book for devs working on Java-like projects。This book goes deep in lots of different strategies to put complex classes into what the author calls a test harness。Some of the techniques presented can be replaced with mocks, and some examples in C++ are irrelevant for me atm。 However the experience shared by the author is invaluable。It has also interesting ways to approach & understand complex software。

Mark Bennett, Jr

Great book to help software engineers integrate good coding practices into old code

Michael Koltsov

The world of software moves with such a pace that this book written in 2004 looks like a relict from the distant past。 However, it's still capable enough to teach the old dog new tricks。These days most of the software is written with a great help from IDEs that have become much more than just text editors。 Every IDE gives you hints on how to optimize your code, most have static analysis tools built-in and most code can be verified even before it gets compiled/interpreted。Although, most IDE have The world of software moves with such a pace that this book written in 2004 looks like a relict from the distant past。 However, it's still capable enough to teach the old dog new tricks。These days most of the software is written with a great help from IDEs that have become much more than just text editors。 Every IDE gives you hints on how to optimize your code, most have static analysis tools built-in and most code can be verified even before it gets compiled/interpreted。Although, most IDE have capabilities to help you refactor your code, they usually run away in tears when they see hundreds of lines of smelly code in one class not covered by any tests。And that's the situation where this book actually shines。 It still can teach you a few trick how to keep yourself sane when you're thrown to the snake pit of filthy legacy code。 And no matter how dated this book is, I'd still recommend it to anyone who finds himself in a situation where he has do maintain what he doesn't even want to touch。My score is 3+/5 Every developer should read this book, but it desperately needs an update 。。。more

Krzysztof

There are nice ideas there, but examples were relevant probably 20 years ago。 If you’re dealing with legacy code then treat it as practice。

Łukasz

I've decided to give two stars to this book。 It introduces reader well to daily routine related to working with legacy code and refactoring as well。 It showing some basic techniques of refactoring。 Code examples are presented in a few programming languages。 It's not the best idea for beginners。In my humble opinion this book is dedicated for junior and medium developer, who doesn't know terms like refactoring/legacy code。 Better choice for more advanced developers is the Martin Fowler's book Ref I've decided to give two stars to this book。 It introduces reader well to daily routine related to working with legacy code and refactoring as well。 It showing some basic techniques of refactoring。 Code examples are presented in a few programming languages。 It's not the best idea for beginners。In my humble opinion this book is dedicated for junior and medium developer, who doesn't know terms like refactoring/legacy code。 Better choice for more advanced developers is the Martin Fowler's book Refactoring: Improving The Design of Existing Code。 It contains much more examples and techniques。 I was expecting much more because of its legend, I'm a little disappointed。 。。。more

Aaron Nance

It's s good book, but in need of an update。 The state of development tools has changed quite a bit in the nearly 20 years since this was written and I feel that many younger developers will have trouble connecting with this book。 It's s good book, but in need of an update。 The state of development tools has changed quite a bit in the nearly 20 years since this was written and I feel that many younger developers will have trouble connecting with this book。 。。。more

Edoardo

So much wisdom and practical advices!I approached this book while starting a new job where my daily job would have been refactoring a legacy PHP codebase。 The general idea applies but consider that "legacy" has different meanings in different languages and especially there are languages easier to test than others。 Patterns described are relevant for statically typed languages so expect that your mileage may vary (most of it is useless in my opinion for Ruby for examples)。Apart from this the key So much wisdom and practical advices!I approached this book while starting a new job where my daily job would have been refactoring a legacy PHP codebase。 The general idea applies but consider that "legacy" has different meanings in different languages and especially there are languages easier to test than others。 Patterns described are relevant for statically typed languages so expect that your mileage may vary (most of it is useless in my opinion for Ruby for examples)。Apart from this the key element I got from the book is: develop an appreciation for the system。 The code written, the business logic, the sweat of developers that before you were reading and writing the code should not be dismantled because "it's legacy"。 There is so much knowledge to extract from legacy and I think this book helped me in understanding how to improve old code with issues (like dependencies, missing edge cases, unclear logic)。 Yes, it's easy to say "write tests", but the point is not "how should I have done this" but "how to save you mind while improving a tangled mess"。I used it more as a general refactoring pattern reference than a text book but has proven valuable。 。。。more

Cezary Piątek

This is yet another book about unit testing。 Mostly describes dirty hacks in c/c++ to bring the legacy code under test。

Enrico

I loved the first few chapters, but after a while it just repeats so often, that it gets somewhat hard to motivate yourself to read on when every chapter seems to offer the same solution: automated testing。 It's great and effective, but I hoped to get some more from this book than just the basics。 I loved the first few chapters, but after a while it just repeats so often, that it gets somewhat hard to motivate yourself to read on when every chapter seems to offer the same solution: automated testing。 It's great and effective, but I hoped to get some more from this book than just the basics。 。。。more

Saifuddin Merchant

It's a decent book and introduces some good techniques to add test cases for legacy code。 The book wasn't particularly useful to me at the moment, for what I am focusing on。 So I let it slide It's a decent book and introduces some good techniques to add test cases for legacy code。 The book wasn't particularly useful to me at the moment, for what I am focusing on。 So I let it slide 。。。more

César

Fantastic book。 A must-read book since most of the software we'll end up working with would be Legacy Code。Legacy code is successful software, software that survived。 But Legacy code it's, often, bad code。 Bad code, the author argues, and I agree, it's code without tests。 It's bad because it hinders the evolution of software to adapt to new requirements while still delivering its current value。Techniques presented in this book such as Characterisation Tests, Effect Sketches and Feature Sketches Fantastic book。 A must-read book since most of the software we'll end up working with would be Legacy Code。Legacy code is successful software, software that survived。 But Legacy code it's, often, bad code。 Bad code, the author argues, and I agree, it's code without tests。 It's bad because it hinders the evolution of software to adapt to new requirements while still delivering its current value。Techniques presented in this book such as Characterisation Tests, Effect Sketches and Feature Sketches are easy to understand and can be applied right away。 I've applied the very next day after reading their chapters and could immediately benefit from them。Some techniques, though, only make sense to certain languages such as Compiler and Link Seams in C, or would be somewhat cumbersome to do in other languages。It would be interesting to have a second edition on modern legacy systems as weird as that sounds。 Systems built with currently popular languages like Javascript, Scala and Go, for example。 A version per language would work great, similarly to what Sandi Metz, Katrina Owen and TJ Stankus did with the second edition of 99 Bottles of OOP though it means, for the author, to write multiple books at once。 。。。more

Dan Drake

A great book, similar to The Pragmatic Programmer: From Journeyman to Master。So, you read books like Clean Code: A Handbook of Agile Software Craftsmanship or Head First Design Patterns, and you get super inspired to write code so beautiful, so elegant, so well-designed that it brings tears to your eyes; the kind of code that other developers, ages hence, will look at in wonder。And then。。。reality。 Reality is a lot of the stuff you deal with was written by someone else, poorly。 Or maybe it was wr A great book, similar to The Pragmatic Programmer: From Journeyman to Master。So, you read books like Clean Code: A Handbook of Agile Software Craftsmanship or Head First Design Patterns, and you get super inspired to write code so beautiful, so elegant, so well-designed that it brings tears to your eyes; the kind of code that other developers, ages hence, will look at in wonder。And then。。。reality。 Reality is a lot of the stuff you deal with was written by someone else, poorly。 Or maybe it was written by you, poorly! Maybe it was fine back in the day but now isn't so good。 This book addresses the practical, pragmatic concerns of someone who came to work this morning and just needs to get something done。 You could very quickly add yet more cruft to this code that you need to modify。。。or you could use the techniques and ideas in this book and produce something more reliable, less buggy, and easier to modify in the future。Of course, it would be even better if the code you work with was well-written in the first place, but it's too late for that。 You need to work with what you've got, and this book helps you do that。 。。。more

Óscar López

This book is a classic in modern software engineering。 What is "legacy code"? Simply put, it's code without unit tests。 The author goes to great lengths to define concepts, vocabulary, techniques and refactorings for understanding and transforming an untested system without breaking it in the process。 The emphasis is mostly on statically typed, object-oriented languages (Java, C++ C#) - which admittedly are harder to test than a dynamically typed language。 There's also a good deal of material co This book is a classic in modern software engineering。 What is "legacy code"? Simply put, it's code without unit tests。 The author goes to great lengths to define concepts, vocabulary, techniques and refactorings for understanding and transforming an untested system without breaking it in the process。 The emphasis is mostly on statically typed, object-oriented languages (Java, C++ C#) - which admittedly are harder to test than a dynamically typed language。 There's also a good deal of material covering techniques for procedural languages (such as C) as well。The topics are arranged in three main sections: first, concepts and definitions are introduced; then a lengthy how-to section answers common questions that appear when dealing with legacy code, and the last part is a catalog of refactorings that can be safely applied without unit tests。 It's difficult to read this book in a linear fashion, it's heavily cross-referenced and will have you going back and forth between sections, it probably deserves a second reading after all the material is covered for the first time。The techniques for understanding a complex, legacy system are low-tech but effective, and involve such simple ideas as drawing the flow of data and dependencies in code, or discussing with the development team about the system responsibilities in order to reverse-engineer its architecture。The core of the book deals with the problem of adding unit tests to a system without them, mostly by breaking code dependencies and identifying the points that should come under test, and also by documenting existing behavior via characterization tests - it's more important to understand what a system actually does (bugs and all!) than what it should do。 All new functionality should be implemented using TDD and ideally, after refactoring and breaking dependencies it'll be possible to test the original code, improving its design as part of the process。What I liked the most is that the author is very pragmatic, and is more than willing to (temporarily) break good design principles (such as encapsulation) to get a class under test。 The truth is that good design and testability are at odds, and we should always prefer code that can be easily tested。 With the techniques in this book it'll be possible to make evolutionary changes; we won't arrive at the ideal design immediately, but we'll be able to make gradual improvements, and first of all we will be able to put tests in place。Not everything's perfect。 There are lots of code typos here and there, and an official erratum is not available。 Many of the refactorings in the catalogue section are workarounds around limitations or lack of tools in old languages, they are useful if you're stuck with an old tech stack, but in a modern OO language they would be unnecessary。 Also several of the described refactorings are quite similar, with only subtle differences between them。And the book is starting to show its age。 The Java examples use a very old version of the language (1。4), where things like generics, enhanced for loops, annotations, streams and lambdas are completely absent。 Modern tools and libraries render a lot of the material obsolete, for example: it's almost certain that we'll have access to a refactoring tool, and the use of a mocking library and a dependency injection library will make our lives way easier。But still, this volume is a very valuable source of information for those cases when we don't have the latest tools at our disposal, and I'd love to see a second edition that takes into account modern practices, especially the use of dynamically typed languages, which nowadays are ubiquitous and make testing such a joy。 。。。more

Anderson Anizio

O antídoto fundamental para lidar com código legado são testes unitários, em torno disso são apresentadas várias técnicas, algumas já desafadas ou inexistentes em muitas linguagens de hoje。É um livro que talvez não faz tanto sentido ler do início ao fim, capítulo por capítulo, mas sim para ser consultado conforme a necessidade。

Alex French

Lots of good stuff。Like so many classics from 2000-2010ish, the focus on Object Oriented languages and techniques really dates it。 The result is that I'm not very interested in a lot of the details, AND I'm deeply suspicious of a lot of the OO-specific techniques。 Lots of good stuff。Like so many classics from 2000-2010ish, the focus on Object Oriented languages and techniques really dates it。 The result is that I'm not very interested in a lot of the details, AND I'm deeply suspicious of a lot of the OO-specific techniques。 。。。more

Gaurav Srivastava

This book is useful if you are adding tests to legacy code as well, otherwise not so much

João Paiva

Found the book quite outdated。 I live the definition that legacy code is code without tests, and the book includes several interesting techniques (even some I'd never used)。 Having said that, the book is mostly about adding unit tests to code single threaded programs written in statically typed languages。 Further, IDEs today can automated most of the techniques described in the book。 In conclusion, I mostly I missed techniques around handling dynamically typed languages and thread-safety issues。 Found the book quite outdated。 I live the definition that legacy code is code without tests, and the book includes several interesting techniques (even some I'd never used)。 Having said that, the book is mostly about adding unit tests to code single threaded programs written in statically typed languages。 Further, IDEs today can automated most of the techniques described in the book。 In conclusion, I mostly I missed techniques around handling dynamically typed languages and thread-safety issues。 。。。more

Scott Holstad

Pretty solid work and timely too as many newer coding tools seem to be supplanting the traditional status quo。 Recommended。

Jeroen De Dauw

Great introductory book to the topic for people not already nose deep in software design。

Greg Stoll

Good book on how to deal with legacy code, although most of the book focuses on how to add unit tests without refactoring a bunch of stuff。 (and of course, you want to have tests in place before you start refactoring things!) There's a bunch of different techniques, some of them particularly sneaky/clever - using the linker in C/C++ to substitute in faked-out functions is clever, but my favorite is using the preprocessor in test files to make different functions be called!There's a whole catalog Good book on how to deal with legacy code, although most of the book focuses on how to add unit tests without refactoring a bunch of stuff。 (and of course, you want to have tests in place before you start refactoring things!) There's a bunch of different techniques, some of them particularly sneaky/clever - using the linker in C/C++ to substitute in faked-out functions is clever, but my favorite is using the preprocessor in test files to make different functions be called!There's a whole catalog of techniques and scenarios ("I Need to Make a Change, but I Don't Know What Tests To Write"), so this will probably be more useful as a reference later on than reading it straight through。I bought this because I was going to be working with some code I thought was legacy-ish, but it turns out the part I wanted to understand/write tests for was actually quite easy to write unit tests for。 But I'm sure I'll have a chance to use it in the future! 。。。more

Maxim Chetruşca

This book is a nice collection of approaches one could use in order to cover any existing code with unit tests。 Perhaps useful for a novice software engineer, I think with practice every caring developer would come up with similar or better techniques。

Leo

远远不及 Refactoring 经典

Daniela

Ótimo leitura para todos os desenvolvedores。 Saber trabalhar bem com legado, faz você não cometer os mesmos erros no futuro。

Tushar Tyagi

Quite a lot of this book can be learned by hit-and-try of doing software。 But it's still a pretty good reference of testing techniques。 Quite a lot of this book can be learned by hit-and-try of doing software。 But it's still a pretty good reference of testing techniques。 。。。more

Matt

I feel this book should be on the reading list for all coders。 The techniques taught here are so important to writing clean and modularized code。 The methods taught to split up code and put parts under test are analogous, I think, to learning how to build jigs when machining。 It just makes things so much easier and more precise to work with。 After reading this book I definitely made a lot of changes to my code, and experienced a huge speed-up in the time it took to add and test new features。

Shayne

Helpful stuff! I had used some of these tactics before, but having names for them helped me codify my approach a little。

Matt

Great book。 There is a reason this one has the reputation that it does。 Do yourself a favour。

Irapuan

This is the best book about refactoring and unit testing that I ever read。 After reading the book, I also did Feathers training, and I also recommend that。