Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
I can’t choose whether someone is offended by my actions. I can choose whether I care.
Why is composing symphonies tough? I don’t know. It’s just very few people in the world can do it well. And I think that’s the case with upfront design. It is very hard to do well.
Comparing to another activity is useful if it helps you formulate questions, it’s dangerous when you use it to justify answers.
Whenever I have to think to understand what the code is doing, I ask myself if I can refactor the code to make that understanding more immediately apparent.
If you can get today’s work done today, but you do it in such a way that you can’t possibly get tomorrow’s work done tomorrow, then you lose.
A heuristic we follow is that whenever we feel the need to comment something, we write a method instead.
When you find you have to add a feature to a program, and the program’s code is not structured in a convenient way to add the feature, first refactor the program to make it easy to add the feature, then add the feature.
Poorly designed code usually takes more code to do the same things, often because the code quite literally does the same thing in several places.
Other than when you are very close to a deadline, however, you should not put off refactoring because you haven’t got time. Experience with several projects has shown that a bout of refactoring results in increased productivity. Not having enough time usually is a sign that you need to do some refactoring.
I’ve found that refactoring helps me write fast software. It slows the software in the short term while I’m refactoring, but it makes the software easier to tune during optimization. I end up well ahead.
Parallel inheritance hierarchies is really a special case of shotgun surgery. In this case, every time you make a subclass of one class, you also have to make a subclass of another.
Life being what it is, you won’t get your names right the first time. In this situation you may well be tempted to leave it – after all it’s only a name. That is the work of the evil demon Obfuscatis; don’t listen to him. If you see a badly named method, it is imperative that you change it. Remember your code is for a human first and a computer second. Humans need good names.
It’s more than a little ironic that many of us preach safety first to our children, nieces, and nephews but in our roles as programmers scream for freedom, a hybrid of the Wild West gunslinger and teenage driver. Give us freedom, give us the resources, and watch us fly.
If you have to spend effort looking at a fragment of code and figuring out what it’s doing, then you should extract it into a function and name the function after the “what”.
It reminds me of a statement Kent Beck often makes about himself: “I’m not a great programmer; I’m just a good programmer with great habits.” Refactoring helps me be much more effective at writing robust code.
First Law of Distributed Object Design: Don’t distribute your objects!
Architectural refactoring is hard, and we’re still ignorant of its full costs, but it isn’t impossible. Here the best.
A statement Kent Beck often makes about himself, “I’m not a great programmer; I’m just a good programmer with great habits.
People sometimes ask me what length I look for in a method. To me length is not the issue. The key is the semantic distance between the method name and the method body. If extracting improves clarity, do it, even if the name is longer than the code you have extracted.
You can Change Your Organization or Change Your Organization.