Programming principles – 5. Premise – We must understand what we’re doing

Books on web development

Video version of this article: https://youtu.be/_SVpX6Q-6zs

Our next premise is that we must understand what we’re doing when programming.

This is also mentioned in the book The Pragmatic Programmer. It’s the tip “don’t program by coincidence”.

Meaning

It means that we must program deliberately.

We should not be “trying things out” until we get something that seems to work.

Explanation

From the definition of software, our requirement is to produce working systems of code.

As we build systems we need to understand what we’re doing, because we’re the ones doing it and building the system.

If we don’t understand, then it follows that we don’t know what we are doing. Therefore we are unaware of whether we’re doing the wrong thing or creating something useful out of absolute luck.

This is a slope.

At first we’re only missing a small bit of understanding and have faith that things will work. We do some manual testing and see that things are working and we’re satisfied. But note that even at this stage we’re programming with luck and hoping it works. It’s just that it’s easy to verify things still work on a small scale using manual testing.

As the system grows bigger, there is a higher chance of error, missing something crucial and breaking something unrelated.

This goes against our requirement that we must create a working system. This is because we don’t know whether we are creating things that work, which means they may not work, which means we may have broken our requirement.

However, if we understand what we’re doing, it means our code is much more likely to work and we’re much less likely to forget or miss something. This is closer to our requirement.

Therefore ideally we should understand what we’re doing at all times.

^