More on this book
Community
Kindle Notes & Highlights
Read between
November 14 - December 10, 2024
you can use a technique called gleaning dependencies. You write tests for the logic that you need to preserve. Afterward, you extract things that the tests do not cover. When you do this, you can at least have confidence that you are preserving the important behavior.
working in legacy code is surgery, and doctors never operate alone.
Move toward interfaces that communicate responsibilities rather than implementation details. This makes code easier to read and easier to maintain.
one pervasive problem in legacy code bases is that there often aren’t any layers of abstraction; the most important code in the system often sits intermingled with low-level API calls.
Code is harder to understand when it is littered with wide interfaces containing dozens of unused methods. When you create narrow abstractions targeted toward what you need, your code communicates better and you are left with a better seam.
Static methods and data really do act as if they are part of a different class. Static data lives for the life of a program, not the life of an instance, and statics are accessible without an instance. The static portions of a class can be seen as a “staging area” for things that don’t quite belong to the class. If you see a method that doesn’t use any instance data, it is a good idea to make it static to make it noticeable until you figure out what class it really belongs on.
Extract and Override Call is a very useful refactoring; I use it very often. It is an ideal way to break dependencies on global variables and static methods. In general, I tend to use it unless there are many different calls against the same global.
Quantum physicists didn’t discover “spooky action at a distance”; in software, we’ve had it for years.
effect sketch A small hand-drawn sketch that shows what variables and method return values can be affected by a software change. Effect sketches can be useful when you are trying to decide where to write tests.
feature sketch A small hand-drawn sketch that shows how methods in a class use other methods and instance variables. Feature sketches can be useful when you are trying to decide how to break apart a large class.

