How to write maintainable software without testing and documentation

Programming is about writing down your knowledge of a complex system in a form which computer can understand. The more the computer knows, the less you need to memorize. We write our knowledge down in different programming language because the system, the knowledge, and our taste are different.

However, programming languages have different level of expressiveness. In JavaScript, we can’t write down the type of a parameter in the function definition. We have to express them in the form of unit testing, documentation, and naming convention. In C, we can’t determine whether a function have side-effects or not without looking into the implementation.

The formula of programming complexity

Here is the formula of programming complexity:

C = P + U

where C is the total complexity we need to achieve to solve the programming task. P is the complexity we can express in the form of code. U is the complexity we have to address in the form of non-code, such as documentation and unit testing.

The more complexity we can address in P, the less U we need.

In other words, if we program in a language can express all kinds of details such as “Is this function pure?", “Does this method mutate the object itself?", “What kind of parameters does the function need?", “Is the function thread-safe?" without looking into the implementation. We can avoid a lots of tedious paper works.

The document will never out-of-date if there’s no need of document.

So, how do we write maintainable software without unit test and documentation?

Choose your programming language wisely

The programming language you choose decided the maximum of P. If the maximum of P is higher than C, you might not need U at all. If your programming language can’t produce a P large enough. You need a huge amount of U to satisfy your C.

Or, choose your problem wisely

The C part of the formula is decided by the task programmer need to do. If we can achieve business requirement with a task with small enough C, we can solve the task with little codes and no document. And we still have a maintainable software because it’s so simple that anyone can understand it in hours, not months.