In the previous post of this series I wrote about the importance of knowing your problem domain, understanding the requirements and defining the tests to be passed.
I am grateful for all the positive feedback I got, but a number of readers felt that it was too long and hard to absorb. So I am going to abandon my initial idea of writing one post per design rule.
By slicing my thoughts and interpretation of Beck’s design rules into smaller chunks and subtopics I also get the possibility to explore the rules more deeply, which I am looking forward to.
Today I dive into Kent Beck’s second rule for simple software design as expressed by Martin Fowler: “Reveals intention”.
That phrase is short, on point, and easy to remember. It is, however, worth taking a look at what the people involved in developing these rules wrote when they discussed the ideas on the original C2 wiki-page:
“The next most important thing [after passing the tests – ed. Note] is that the code is as easy to understand as possible, therefore we need to ensure that it expresses every idea that we need to express clearly”
— Jason Yip
It’s important to remember that we don’t write code for machines. If we did, we could (and should) write binary code. Since we write code to be understood and maintained by other people, we don’t, because we humans are not naturally able to get the meaning of huge blocks of 0 and 1.
Any code we write serves two purposes:
- Make the machine behave in the way we want
- Tell the reader what we expect that behaviour to be
While the first purpose seems obvious, we often forget about the second one, which is although equally important if we aim for low maintenance cost and long-term success.
So how can we make our code readable and understandable? What are the possibilities we have, particularly in database development?