Three good reasons to reorganize:
- Your original design (perhaps in a very small area, but the design nonetheless) was wrong. This includes where you discover a common operation and want to share code.
- You are developing iteratively.
- The code is so bad that it needs a complete overhaul.
Three good reasons not to refactor:
- "It looks a little dirty."
- "I don't quite agree with how the last guy did it."
- "It could be more effective." (The problem is "may").
“Merciless” controversial - there is a valid argument, which is called “fixing broken windows” or “code hygiene”, which suggests that if you let small things slip, you will also start to skip big things. It is beautiful, and it’s good to remember, but remember that it is an analogy. He does not justify shunting material endlessly, in search of the cleanest possible solution.
How often you, refactoring, should depend on how often good reasons arise and how confident you are that your test process protects you from errors.
Refactoring is never an end in itself. But if something does not work, it must be fixed, and this is true both in the initial development and in the maintenance. For nontrivial changes, it is almost always better to refactor and incorporate new concepts into cleanliness than to fix one place with large chunks of garbage to avoid any changes elsewhere.
For what it's worth, I don’t think about changing the interface, provided that I have a handle to what uses it and that the area of the resulting change is manageable.
Steve Jessop Sep 26 '08 at 17:12 2008-09-26 17:12
source share