HomeGroupsTalkMoreZeitgeist
Search Site
This site uses cookies to deliver our services, improve performance, for analytics, and (if not signed in) for advertising. By using LibraryThing you acknowledge that you have read and understand our Terms of Service and Privacy Policy. Your use of the site and services is subject to these policies and terms.

Results from Google Books

Click on a thumbnail to go to Google Books.

Working Effectively with Legacy Code (Robert…
Loading...

Working Effectively with Legacy Code (Robert C. Martin Series) (edition 2004)

by Michael Feathers

MembersReviewsPopularityAverage ratingMentions
689833,247 (4.31)3
Great book, but get's kinda tedoius. Abstract interface, abstract implementation, so on and so on. However, I consider it to be a must read for programmers who don't work at startups (ie inevitably deal w/ legacy code). ( )
  sangahn | Aug 20, 2009 |
Showing 8 of 8
One of the best books I read in my life!!! Definitely reread this book at least couple times. ( )
  kmaxat | Aug 26, 2023 |
Very good. ( )
  NachoSeco | Oct 10, 2022 |
We wise programmers know that code should be written to minimize dependencies, inject those that are necessary, use interfaces, be tested from the start, etc. etc., and we always write our new code like that (right?), but our good habits and wisdom don’t matter when working with legacy code. You don’t have the option of going back in time and smacking some sense into the original author (who may have been your younger, more foolish self).

Given that we have to deal with legacy code, how can it be made easier? The fundamental premise of Working Effectively With Legacy Code is that you cannot work effectively with code unless it is covered by tests. When working with untested code you must be extremely careful, and even then the results are uncertain.

As a result, the bulk of this book is dedicated to techniques for helping get legacy code under test (specifically, fast running unit tests). Many of the techniques used for working with legacy code are well known testing or refactoring patterns, but Feathers puts them in a new light which highlights some of the special difficulties of working with legacy code.

Unlike code that was written with tests in mind, legacy code can be notoriously hard to test. The main enemy of getting tests in place is complex dependencies. To test a piece of code, you may have to create many other configuration objects, and some of those may be impossible/expensive to create in tests (e.g., live network connections). Even worse, you may not even have the hooks to create those objects because they are created deep within the code.
This brings up what Feathers calls “The Legacy Code Dilemma”:
When we change code, we should have tests in place. To put tests in place, we often have to change code.

To get around this dilemma, Feathers introduces the reader to low risk ways to introduce tests into existing code. Because these changes still have some risk, he recommends only adding tests to code you are working on. Don’t just go and start introducing tests everywhere because that requires changing code and may introduce bugs.

Feathers presents a catalog of techniques for introducing tests and breaking dependencies. I won’t go into them in detail (there are a lot). I will note that I am not that fond of the format of the chapters. Feathers names each chapter as if it were a question in a FAQ and then uses the chapter to answer that question. This will probably be great when I am trying to do something and think, “Didn’t that book have something to say about that?”, but it feels kind of hokey when just reading it as a book.

There are some common themes throughout this book. Dependency breaking is one. Another is that sometimes you have to make code more ugly to get it under test. You may have to add partial interfaces or classes that exist only to break the dependencies. Feathers gives two pieces of advice to get over that: it’s better to have tested code than untested code, and often the ugliness is an intermediate stage in unearthing the deeper structure of the code.

This book is not all about testing, however. Feathers does spend some time talking about techniques for understanding legacy code and discovering where to change it. In fact, those were some of my favorite chapters since I find getting started on understanding complex code bases to be rather intimidating. Chapters 11, 12, 16, and 17 discuss techniques for understanding code. Feathers talks about different ways of increasing understanding including sketching effects, taking notes about code, scratch refactoring, and telling the story of the system. I have found the effect sketching to be particularly useful in my day-to-day work.

Overall, this was a valuable read for anyone who has to understand and change large, confusing, delicate code bases (and what code base that has been around awhile isn’t?). The structure of the book made it repetitive at times, but the value of the contents outweighed the occasional repetition. ( )
  eri_kars | Jul 10, 2022 |
If you write software with other people, for fun or money, you should read this book. It's the best writing on how to get messy, awful software on the road to sanity, step by incremental step. ( )
  thegreatape | Jan 7, 2020 |
A very detailed manual on how to stop worrying and to get your code under tests. It should say "don't panic" on the cover. It really covers a lot of techniques with their drawbacks and benefits. I can imagine referring back to this book as a reference in hard cases. I did not fully internalize all the methods yet, but what I read in this book is already helping me daily and keeping me more confident about my code as a result. ( )
  valdanylchuk | Aug 26, 2015 |
Great book, but get's kinda tedoius. Abstract interface, abstract implementation, so on and so on. However, I consider it to be a must read for programmers who don't work at startups (ie inevitably deal w/ legacy code). ( )
  sangahn | Aug 20, 2009 |
This book provides some great insight into writing testable code even if you are not dealing with a "legacy" code base. His style is great and it really is an interesting and comfortable read. ( )
  mgholls | Oct 30, 2008 |
Showing 8 of 8

Current Discussions

None

Popular covers

Quick Links

Rating

Average: (4.31)
0.5
1
1.5
2 1
2.5 1
3 18
3.5 1
4 39
4.5 4
5 57

Is this you?

Become a LibraryThing Author.

 

About | Contact | Privacy/Terms | Help/FAQs | Blog | Store | APIs | TinyCat | Legacy Libraries | Early Reviewers | Common Knowledge | 204,520,712 books! | Top bar: Always visible