the best books for developers
Topics: Legacy Code, Testing, Code Refactoring, Design Patterns, Test-Driven Development, Software Design Patterns, Software Maintenance
By Michael Feathers
"Working Effectively with Legacy Code" by Michael Feathers is like your trusty guide to dealing with messy, old code that makes you want to pull your hair out. This book is all about taming those wild, legacy codebases that have been passed down through the generations of developers.
So, first off, Feathers talks about what the heck legacy code even is and why it's such a pain. He doesn't sugarcoat it – legacy code is often a hot mess, and it feels like wrestling an angry octopus.
But fear not! He gives you practical tips and strategies to bring that code under control. He talks about techniques like "seam" – finding ways to change the code without breaking it, and "sprout" – adding new code to pave the way for improvements.
You'll also learn about unit testing and how it can be your secret weapon for making changes without introducing bugs. Feathers gives you the lowdown on refactoring – safely cleaning up the code without causing chaos.
One big takeaway is the importance of having a safety net of tests around your code. It's like having a cushion for your coding adventures. You'll also dive into dependency-breaking techniques, which is like detangling a web of spaghetti.
In the end, this book is like a survival guide for developers stuck in the legacy code wilderness. It's full of practical wisdom and battle-tested techniques to help you turn that spaghetti code into something you can actually work with. So if you're in the trenches with legacy code, this book is your best buddy!
Chapter 1: Changing Software
In the opening chapter, Michael Feathers discusses the challenges of working with legacy code, defines what legacy code is, and emphasizes the importance of maintaining and improving it.
Chapter 2: Working with Feedback
Chapter 2 explores the significance of feedback in legacy code projects. It explains how automated tests and testing strategies can provide feedback and help make incremental changes with confidence.
Chapter 3: Sensing and Separation
This chapter focuses on techniques for understanding and separating dependencies within legacy code. It introduces strategies for identifying seams where you can introduce changes without affecting the whole codebase.
Chapter 4: The Seam Model
Chapter 4 elaborates on the concept of seams introduced in the previous chapter. It provides practical guidance on creating and using seams effectively to facilitate testing and refactoring.
Chapter 5: Tools
In this chapter, Feathers introduces various tools and techniques that can assist in working with legacy code, including refactoring tools, automated testing frameworks, and version control systems.
Chapter 6: I Don't Have Much Time and I Have to Change It
Chapter 6 addresses the common scenario where developers have limited time to make significant changes in legacy code. It presents strategies for making impactful improvements even with time constraints.
Chapter 7: It Takes Forever to Make a Change
This chapter explores the reasons why some codebases are challenging to work with and proposes methods to speed up the development process when dealing with legacy systems.
Chapter 8: How Do I Add a Feature?
Chapter 8 provides insights into adding new features to legacy code while maintaining code quality and minimizing risk. It introduces techniques such as characterization tests and branching by abstraction.
Chapter 9: I Can't Get This Class into a Test Harness
In this chapter, Feathers addresses the difficulties of testing classes that resist being placed into a test harness. He provides strategies to overcome these challenges and make such classes testable.
Chapter 10: I Can't Run This Method in a Test Harness
Chapter 10 focuses on testing methods that are particularly challenging to isolate and test. It presents techniques for dealing with methods that have undesirable side effects or dependencies.
Chapter 11: I Need to Make a Change. What Methods Should I Test?
This chapter discusses prioritizing which methods to test when dealing with legacy code. It guides developers in identifying critical paths and areas where testing will provide the most value.
Chapter 12: Dependencies on Libraries Are Killing Me
Chapter 12 addresses the challenges of dealing with external libraries and frameworks in legacy code. It provides strategies for managing and isolating dependencies effectively.
Chapter 13: My Application Is All API Calls
In this chapter, Feathers tackles codebases heavily reliant on external APIs and services. He offers techniques for testing and refactoring code that interacts extensively with external systems.
Chapter 14: I Don't Understand the Code Well Enough to Change It
Chapter 14 discusses methods for gaining a deep understanding of legacy code, including techniques for reading and analyzing code effectively.
Chapter 15: We Can't Get This Code into a Test Harness
The final chapter addresses situations where code is exceptionally resistant to testing. Feathers provides advice on when to refactor versus when to leave well enough alone, based on practical considerations.