Refactoring: Improving the Design of Existing Code (Addison-Wesley Signature Series (Fowler))
Rate it:
Open Preview
5%
Flag icon
By writing what I want twice, in the code and in the test, I have to make the mistake consistently in both places to fool the detector.
Rich liked this
7%
Flag icon
I’ll just observe that this change is unlikely to significantly affect performance, and even if it were, it is much easier to improve the performance of a well-factored code base.
7%
Flag icon
With good names, I don’t have to read the body of the function to see what it does. But it’s hard to get names right the first time, so I use the best name I can think of for the moment, and don’t hesitate to rename it later.
Rich liked this
13%
Flag icon
If someone says their code was broken for a couple of days while they are refactoring, you can be pretty sure they were not refactoring.
15%
Flag icon
I’m reluctant to have a team do dedicated refactoring. Often, a useful strategy is to agree to gradually work on the problem over the course of the next few weeks. Whenever anyone goes near any code that’s in the refactoring zone, they move it a little way in the direction they want to improve.
15%
Flag icon
Of course, many managers and customer don’t have the technical awareness to know how code base health impacts productivity. In these cases I give my more controversial advice: Don’t tell!
15%
Flag icon
If I run across code that is a mess, but I don’t need to modify it, then I don’t need to refactor it.
16%
Flag icon
But I think the most dangerous way that people get trapped is when they try to justify refactoring in terms of “clean code,” “good engineering practice,” or similar moral reasons. The point of refactoring isn’t to show how sparkly a code base is—it is purely economic.
17%
Flag icon
To really operate in an agile way, a team has to be capable and enthusiastic refactorers—and for that, many aspects of their process have to align with making refactoring a regular part of their work.
18%
Flag icon
The lesson is: Even if you know exactly what is going on in your system, measure performance, don’t speculate. You’ll learn something, and nine times out of ten, it won’t be that you were right! — Ron Jeffries
19%
Flag icon
By now you have a good idea of how refactoring works. But just because you know how doesn’t mean you know when. Deciding when to start refactoring—and when to stop—is just as important to refactoring as knowing how to operate the mechanics of it.
19%
Flag icon
a good name can save hours of puzzled incomprehension in the future.
19%
Flag icon
A heuristic we follow is that whenever we feel the need to comment something, we write a function instead.
Rich liked this
21%
Flag icon
We find many programmers are curiously reluctant to create their own fundamental types which are useful for their domain—such as money, coordinates, or ranges.
Rich liked this
24%
Flag icon
trying to write too many tests usually leads to not writing enough.
24%
Flag icon
I get many benefits from testing even if I do only a little testing. My focus is to test the areas that I’m most worried about going wrong. That way I get the most benefit for my testing effort.