The value system

Clean code developers have a Value system. It consists of the four values described below:

  • Changeability
  • Correctness
  • Production efficiency
  • Continuous improvement

Table of contents

Changeability

We would like to begin this section with a seemingly provocative thesis:

There is no software maintenance!

Maintenance is a proactive process. In production systems, parts are regularly replaced before they break. They are replaced because experience has shown that reliability would fall below a critical value if operation were to continue. So before the entire system comes to a standstill, the critical parts are replaced in good time. Every car owner knows that they need to have their oil changed regularly. Not because the oil is used up at that point, not even because the oil is already completely ineffective at that point. No, it is changed because the manufacturer's experience shows that the engine is protected by changing the oil in good time and therefore lasts longer.

None of this exists with software. Software is what it is. It usually contains errors. But even these errors are the way they are. Nothing can be done proactively to improve the state of the software.

Of course, there are proactive actions when operating the software. For example, it may be necessary to regularly check whether the log files still have enough free space on the hard disk, whether a database is overflowing or whether the memory is filling up. But the software itself cannot be maintained proactively. Every change or extension is made to eliminate an error or to implement new or changed requirements.

For changes to be possible, the software must have an internal structure that favors such changes. We refer to this as changeability. Software is usually operated over long periods of time. During this time, the framework conditions change and features need to be added. Ideally, the implementation of a feature costs a fixed amount that is independent of when the feature is realized.

In practice, however, the price of a feature increases the later it is implemented. In the beginning, features are inexpensive, but in the end it is no longer possible to add features because nobody can see through them. The software is thrown away and redeveloped. Until you reach this point, the costs increase exponentially. There are two common things about exponential growth: 1) Initially, you hardly notice that the costs are increasing. The increases are moderate. 2) By the time you realize that costs are rising, it's too late. The increase then suddenly progresses so quickly that it is no longer possible to counteract it.

The easier the software can be adapted to changing conditions, the greater its adaptability. But changeability cannot be achieved retrospectively. It must be taken into account from the outset. The software must be designed for it.

Here is an example: classes should have exactly one responsibility. If a class is responsible for more than one thing, it is more difficult to keep track of it. This hinders changes because they require an understanding of the source code that is to be changed. Furthermore, the coupling between the classes increases. Suddenly everything is connected to everything else. This can only be prevented if functional units have clearly defined responsibilities and you keep an eye on the coupling. If you have accumulated a number of classes in a software system, each of which is responsible for several things, it is difficult to eliminate this situation retrospectively. The coupling is so large that it is difficult to separate out individual functional units. If new features are to be implemented in this thicket, it is very time-consuming. If a start is not made in good time to clear out the thicket, the situation gets worse every time. At a certain point, it becomes almost impossible to add new features. The super-GAU of software development.

We believe that it doesn't have to come to this. If changeability is taken into account from the outset, software can continue to be developed over long periods of time. The costs per feature may increase slightly over time. But by no means exponentially!

Correctness

Software must be functionally correct. An accounting program must post entries correctly, a spreadsheet must calculate correctly. And the non-functional requirements must also be fulfilled. The program must use resources such as memory, processor time, disk space, etc. sparingly and the response times must be within a defined range. Only when all requirements are met is the software created correct.

No one will deny that correctness is necessary. But the question is what is actually done to achieve this. In our opinion, it is not enough to run software through a test department after it has been created, whose job it is to find errors. We believe that correctness must already be taken into account during development. Even the developers have to deal with the issue of correctness. And for them to be able to do this at all, they must be clear about what the requirements are. All too often this is lacking. Developers are commissioned to implement a feature without being told precisely what the acceptance criteria for the feature are. But this is not about passing the buck and looking for someone outside the development departments to blame. After all, it is the developers' job to ask questions when requirements are unclear, rather than looking into their crystal ball.

Compared to automotive engineering, software development has a poor record when it comes to correctness. A car consists of many parts, the correctness of which can be verified and checked individually. Imagine you had to sit on the hood of the car with a measuring device in your hand to check what was happening in the engine. At 200 km/h on the highway. Seems strange to you? A debugger is used in exactly the same way in many cases. We think that's wrong.

Production efficiency

Ultimately, of course, the development time and the price of the software also play a role. And this is higher if the software is not produced efficiently. This starts with manual work steps that are not automated and ends with high error rates that require repeated reworking. Ultimately, production efficiency means that the software can be further developed over years or even decades instead of having to start from scratch at some point. At the same time, high production efficiency reduces the susceptibility to errors.

Production efficiency as a value is also important in order to keep the other values in proportion. If you go to endless lengths to ensure correctness, you will end up doing something wrong.

Continuous improvement

No further development is possible without looking back. Only those who reflect on how they have solved a task can determine whether the chosen path was easy or difficult. Learning is based on reflection.

In a young science such as computer science, it is important to constantly take new findings into account. This requires reflection at all levels. Starting with reflection on implementation during pair programming or code review, the daily reflection of the team, reflection after each iteration, through to the reflection of the entire industry on its actions. Without reflection, there can be no further development.

Principles and practices

The value system guides Clean Code developers in their daily work. It does not contain solutions to problems, but rather defines framework conditions for solving problems. However, the four values are too abstract for concrete day-to-day implementation. We have therefore compiled building blocks that each promote at least one of the values. We divide these concrete building blocks into two categories: Principles and Practices.

Principles

The Clean Code Developer Principles are the basic principles for structuring software. They are either orthogonal to other framework conditions or superior to them. Code should always be in accordance with a maximum number of principles. Of course, they do not have "the power" of laws of nature, which no-one can contradict. But they are on a par with them in terms of their fundamentality with regard to software development. Where a principle is not adhered to, a negative effect does not necessarily occur immediately, but in the short to medium term, violations are not without pain. This is expressed in the difficulty of understanding the code or in the high effort required to introduce changes. It is ultimate when software can no longer be evolved. You can always tell from the code whether a principle has been adhered to.

Practices

Practices are techniques and methods that are constantly used. They describe what clean code developers do in practice. Motto of the practices: "Always do it this way. Every day, every time." They are tangible instructions that sometimes require the use of tools. You cannot always tell from the code whether a practice is being followed.

en_USEnglish