In the early days of computing, computers were relatively slow. Almost anything that could be done to shave off a few instructions was worth the effort. The most efficient use of any of the resources on the very expensive computer system was the major goal. Things have changed. The most valuable resources is now people: people to develop the software, people to maintain the software, and people to enhance capability. With few application exceptions, programmers should think first of the people who will later attempt to understand and adapt the software. Anything that can be done to assist them should be done.
1 Efficiency is also important,
2 but they are not mutually exclusive. If you need efficiency, that's fine but upgrade the readability of your program so that you don't lose the humans in the process.
- Avoid Tricks
Avoid Global Variables
Write To Read Top-Down
Avoid Side-Effects
Use Meaningful Names
- Evaluate Alternatives
Use Efficient Algorithms
Get It Right Before You Make It Faster
Reference:
McConnell, S., Code Complete, Redmond, WA: Microsoft Press, 1993.