DEV Community

Discussion on: Should comments in code be considered failures in coding?

Collapse
 
combinatorylogic profile image
combinatorylogic

What?!?

Why is far more important than "how". And you cannot convey this "why" part in code, its semantics is not fit for this.

"Why" includes a lot of things - what's the reason for this code to even exist, why it's making all those assumptions about the input data, why this particular optimisation is chosen and what extern performance constraints were taken into consideration.

There is always far more of the "why" part of the story than the actual code. Code is trivial and immaterial, while "why" is all that matters in a large scale.

Thread Thread
 
rossdrew profile image
Ross

"why" is all that matters in a large scale.

Very rarely has the why mattered unless you are doing something very silly or something very specialised. One case is common and is what we are talking about, the other is the exception that proves the rule.

Code is trivial and immaterial, while

I find that kind of attitude is what leads to bad code excused by comments. Code isn't important, comments are is just a crazy, dangerous notion to me.

Thread Thread
 
combinatorylogic profile image
combinatorylogic

Very rarely has the why mattered unless you are doing something very silly or something very specialised.

How comes? You always start with "why?". Pardon my tautology, but "why?" is exactly why you're writing your code in the first place. How can you argue it's not really that important if it's the only thing that's really important and code is only secondary to it.

One case is common and is what we are talking about, the other is the exception that proves the rule.

I cannot really think of a single case where "why" is less important than all of the "how" code. Not a single one. Maybe, training toy problems that are designed solely to practice coding skills are a bit of an exception, but in actual practice you won't find a single case like this.

I find that kind of attitude is what leads to bad code excused by comments.

All code is bad. By definition. You must avoid it as much as possible. The less code - the better.

And having proper literate comments is a good way to get rid of code.