The Psychological Case For Clean Code

This is a little bit of philosophising that came out of a (misunderstood, as it happens) request by Marcel Du Preez for a list of things that characterise clean code. See what you think.

The Psychological Case For Clean Code

The following is how working on clean code makes programmers feel, and as such, for our own sakes, why we all should give a damn about it.

Writing code is a creative process, we feel the code itself represents who we are as professionals and as people. We judge ourselves and others by it, just as a musician is judged by the quality of the music they perform. It matters.

So, here is how we feel when we work with clean code:

Productive
We spend very little time debugging, deciphering code or reworking badly written classes. When we start a new feature, we can work on it straight away rather than have to re-steady the foundations all the time. Estimation is not daunting – we know even complex features will be smooth, predictable.

Clear headed
The code speaks to us, takes it easy on us. We only need to understand a few things at a time, not massively interweaved concepts. Abstractions are consistent, tangible. We know exactly what we are working on at any one time, we can explain it to someone else in a few sentences.

Motivated
We like working in the code. Progress is always being made. Things actually get easier as time goes on, compelling us to stick with it, even under pressure, so we can reap the rewards.

Confident
We are not scared to make changes. We are bold, feeling free to refactor, rip everything apart. We know if something goes wrong, we’ll be the first to know, and no-one will get hurt.

Competent
We understand the code, even when it achieves extremely complex things. We are not confused, the code is learnable. We feel like a better programmers having worked on it.

Ambitious
We sense the code is already powerful, well thought out. We have clear ideas about how we can make it even more capable. The potential is so ripe, that out goals grow. We can’t help say yes to features, because we can see so much is possible.

Proud
It is an honour to work on the code. We want it on our CVs. We blog about it, we are happy to publish code snippits. When new members join the team, we can’t wait to show them the best bits.

Vigilant
We hate seeing the code spoilt – we take issue when bad code is committed. We refactor when new code isn’t as good as what is already there. We believe the code deserves to get better every day. Hacks are just revolting. We reject bad ideas that don’t make the grade.

Calm
Nothing in the code scares us. It does what it is supposed to. Deadlines are not overwhelming, as we know strange bugs will not appear at the last minute.

Open minded
We are not afraid of someone coming in with criticism, new ideas. The code doesn’t require a defensive attitude to maintain team members’ self esteem, it can stand it. Anyone can see it is good already, any way to make it better is welcome.

To wrap it all up, clean code makes programmers feel in the flow, in control. For businesses that rely on software, this can have more effect than most people even dare to imagine.

Leave a comment