Logo dévoreur 2 code

Tests and Code Quality - What's the Point?

Written by Fabien SchlegelFabien Schlegel
published 8/26/20192 min

Tests are useless!

Visitor from here and elsewhere, you will often hear these words from code makers…

The guy who estimated your project surely added time for tests, but it got eaten up because we’re late, there’s no budget, think of my retirement in Thailand, blah blah blah…

Tests, what are they?

Tests save your life when they are well done and well thought out.

Their primary purpose is preventing code regressions.

A real-life example:

You develop a feature and, a week later, someone uses one of your functions elsewhere in the project.

They modify it and, ping, your feature, beautiful and well made of course ;) crashes…

The second purpose is bugs:

Even though you’re at the top of your game, when you start writing functions that want to have their cake, eat it, and keep the baker smiling, you can’t foresee everything.

By testing every if/else, for loop and so on, you often eliminate the risk of side effects in the code, and sometimes you find problems you hadn’t spotted on first reading.

What about code quality, then

Writing higher-quality code matters for lots of reasons.

You come back to it three months later, and there, variables a, b, c and the GolDoRak class are a disaster.

The person who maintains the project after you will curse you for 10 generations.

The first solution lies in the names of variables, classes and functions. The clearer their names, the better the associated code is understood.

The second is writing comments. They help you understand what you meant to do, especially three months later.

Here are links to coding style guides. They gather good practices to follow for Javascript and Python.

If you want me to add the one for your favorite language, send a message, it will be a pleasure…

That’s all for now

An introduction to the topic with a bit of reading for the brave. I hope you enjoyed it.

The next articles will go into more detail with Javascript and Python examples.


This post is the first of a series on tests and code quality.

Share the post

Table of contents