Foreword
Acknowledgments
Introduction: There is a lot of legacy, out there
- Legacy code
- You didn’t become a developer for this
- There is a lot of legacy, out there
- Part I: Approaching legacy code
Chapter 1: The right attitude to deal with legacy code
- The natural reaction: who the f*** wrote this
- A humble view of legacy code
- The efficient approach: taking ownership
- Having a role model
The Legacy Code Programmer’s Toolbox
Chapter 2: How to use bad code to learn how to write great code
- Don’t like the code? Elaborate, please.
- The vaccine against bad code is bad code
- Be aware of what good code looks like
Chapter 3: Why reading good code is important (and where to find it)
- The importance of reading good code
- Where to find good code
- Become more efficient with legacy code
- Part II: 10 techniques to understand legacy code
Chapter 4: 3 techniques to get an overview of the code
- 1) Choosing a stronghold
- 2) Starting from the inputs and outputs of the program (and how to find them)
- 3) Analysing well-chosen stacks
Chapter 5: 4 techniques to become a code speed-reader
- 1) Working your way backwards from the function’s outputs
- 2) Identifying the terms that occur frequently
- 3) Filtering on control flow
- 4) Distinguishing the main action of the function
Chapter 6: 3 techniques to understand code in detail
- 1) Using “practice” functions to improve your code-reading skills
- 2) Decoupling the code
- 3) Teaming up with other people
- It gets easier with practice
- Part III: Knowledge
Chapter 7: Knowledge is Power
- Where did the knowledge go?
Chapter 8: How to make knowledge flow in your team
- Writing precious documentation
- Telling your tales: acquiring knowledge in Eager mode
- Knowing who to ask: getting knowledge in Lazy mode
- Pair-programming and mob-programming
- External sources of knowledge
- Make the knowledge flow
Chapter 9: The Dailies: knowledge injected in regular doses
- What are Dailies?
- Monthly sessions
- The major benefits of Dailies
- There is plenty of content out there
- Be the one who spreads knowledge
- Part IV: Cutting through legacy code
Chapter 10: How to find the source of a bug without knowing a lot of code
- The slowest way to find the source of a bug
- The quickest way to find the source of a bug
- A binary search for the root cause of a bug
- A case study
Chapter 11: The Harmonica School: A case study in diagnosing a bug quickly in an unfamiliar code base
- Lesson subscriptions
- Let’s find the source of that bug, quickly
- The more time you spend in the application, the less total time you spend debugging
Chapter 12: What to fix and what not to fix in a legacy codebase
- Legacy code is a bully
- The value-based approach (a.k.a. “Hit it where it hurts”)
- Where does it hurt?
- Use the value-based approach
Chapter 13: 5 refactoring techniques to make long functions shorter
- The birth of a Behemoth
- Identifying units of behaviour
- 1) Extract
forloops - 2) Extract intensive uses of the same object
- 3) Raise the level of abstraction in unbalanced
ifstatements - 4) Lump up pieces of data that stick together
- 5) Follow the hints in the layout of the code
- 6) Bonus: using your IDE to hide code
- The impact on performance
Conclusion: The legacy of tomorrow
- The bigger picture of writing code
- How to deal with legacy code
- But you’re also person A
- Parting words
