What is bad code?

stereobooster - Aug 12 '19 - - Dev Community

Seems to be an obvious question, but I haven't seen one authoritative answer to this. People can have opinions about code quality for sure, or people can use phrases like "Bad code is bad code, whether it compiles or not." (from this article).

But can we define what is bad code? Can we all agree on that one definition?

I guess this definition will change over time. Shall we make a committee which will publish a new definition every year?

What I'm trying to say is that this is not a trivial problem to decide if this code is bad or is good, the same way as it is hard to say if this is the best chess move or not (I can give you an answer, but how you gonna know it is true, it is hard to test).

It is possible to identify some parameters of code, like LoC, coverage by tests.

Other parameters are harder, for example, readability. Readability depends on the reader.

We - developers like to throw around those terms like 10x programmer, bad code, etc. But in practice those terms like mythical creatures. Everybody has different ideas, sometimes definition is "I know it when I see it".

How we suppose to have constructive discussion throwing those ambiguous terms around.

Photo by Maria Teneva on Unsplash

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .