I have been reading Practical Data Structures in C++ now a days. There the author suggests the following design principles while writing a program:
- Maintain the viewpoint of a practitioner: By this the author intends to say that first get the program working, by whatever inelegant means, then try to find more elegant ways of doing the same thing, provided it is warranted.
- There is no such thing as a complex solution: Keep the design as simple as possible. The simple solution is separated from you not by distance, but by time.
- Don’t overgeneralize: Over generalizing can lead to a lot of special cases and thus may incur a lot of overhead.
- Follow the 80-20 rule: Spend most of your effort on that 20% of code.
- Design first, then optimize: He means that do the optimization first at the design level and then at the implementation level.
- Try to get the most leverage out of any overhead you introduce.
- You shouldn’t have to pay for something that you are not going to use.
The last two principles need some thought.