DEV Community

Alex Pushkarev
Alex Pushkarev

Posted on β€’ Edited on

2 1

How to tell if the code is clean?

Clean code is a buzzword and a boogieman in the software industry. There're books called "Clean code" and there're social-network-based fights on what could be called "clean code" and what couldn't.

Image description

Why it is difficult to create a "clean code formula"? I have been thinking about it lately and I think I was able to come up with something interesting.

Programming code we write is not only instructions for a computer, but also a form of communication. Just think about it - we try to write something which:
πŸ‘‰ can be understood by a computer
πŸ‘‰ can be reasonably easy read (and written!) by programmer
πŸ‘‰ is reasonably easy to change
πŸ‘‰ as well as communicate the "grand plan" of a software system architecture

And I haven't yet mentioned that it should be:
πŸ‘‰ reasonably efficient (with every task having different efficiency requirements)
πŸ‘‰ and not consume unnecessary memory.

Clearly, it is not an easy task. It also isn't something100% objective and/or measurable.

Different people have different readability "requirements". I am assuming this is mostly defined by what kind of code they were exposed to, but there might be something else going on.

A similar challenge is with "grand plan"/"architecture" communication - depending on what kind of applications one worked with as well as personal paradigm preferences there may be quite big differences in understanding of what could be a good architecture direction.

The worst thing is that in many cases the objective differences are, in fact, marginal. Similarly "code smells" are just heuristics and not definitive tests.

So, while it is great if you care about writing clean code, keep yourself open-minded and never assume that you know "the formula"

Interested? Then check out the next post on clean code - "The most important code smells"

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

πŸ‘‹ Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay