In his book Code Simplicity, Max Kanat-Alexander lists six laws of software design in an appendix. These are a pretty good set of rules!
It is interesting to me to note how these 6 laws relate to other platitudes of software design and development, such as “Do the simplest thing that works”, “You ain’t gonna need it”, The Law of Demeter (aka Principle of Least Knowledge) and several others. They are saying the same sorts of things, but perhaps slightly different perspectives.
There is nothing new here, really, but the collected wisdom from people who have slogged through software development projects and survived.
The Six Laws of Software Design
The purpose of software is to help people.
The Equation of Software Design:
D = (Vn + Vf) / (Ei + Em)
- D: Stands for the desirability of the change.
- Vn: Stands for value now.
- Vf: Stands for future value.
- Ei: Stands for the effort of implementation.
- Em: Stands for the effort of maintenance.
This is the primary law of software design. As time goes on, this equation reduces to:
D = Vf / Em
Which demonstrates that it is more important to reduce the effort of maintenance than it is to reduce the effort of implementation.
The Law of Change: The longer your program exists, the more probable it is that any piece of it will have to change.
The Law of Defect Probability: The chance of introducing a defect into your program is proportional to the size of the changes you make to it.
The Law of Simplicity: The ease of maintenance of any piece of software is proportional to the simplicity of its individual pieces.
The Law of Testing: The degree to which you know how your software behaves is the degree to which you have accurately tested it.