Daniel Prinz | Dev Courses

What is clean code and why should you care?

What is clean code and why should you care?

Right after school I began to work on my first software project. I implemented feature after feature and was happy that it worked. Nowadays, writing code is different for me. I think more in how should I write code for readability and testability.

Buy why should you care about this principles, if the software is working without it?

It is very rare that one piece of code has been written once and never changed again.

The requirements for the software service you are working on are changing over time. Adding, changing and removing features is a day-to-day business. Sometimes bugfixes have to be done fast and effectively. As long as the software service stays small, it may be ok if the code is not so good. Over time you will see the advantages if you keep the code tidy and easy to understand.

Why should it be easy to understand?

Because most of the time you are reading code, before you can write code. And not only you, also your co-workers are reading through code and should be able to understand it. Applying the clean code principles saves an enormous amount of time in the future.

The following graphic illustrates this quite well. In the beginning the cost of change is low, however over time it increases exponentially. When using clean code, the cost per change stays on a proper level:

code ratio Image Source: Geeks for Geeks

With that in mind, I am always aiming for clean code, however I also keep in mind that code is never perfect. So I limit the time when refactoring code to achieve a good balance between developing new features and keeping the code as clean as possible.

A book that I can definitely recommend is Clean Code from Robert C. Martin . It describes the essential things about clean code every programmer should know.

What is clean code and why should you care?
Prev post

The 4 steps to give effective feedback

Next post

How the JVM chooses the default garbage collector.

What is clean code and why should you care?

Get in touch

Reach out if you want to get in contact with me or if you have some conent requests for my courses.