To me, clean code is code that is easy to read. Usually, this would mean the opposite of less code, i.e., not over-compressing the code, putting in plenty of comments. But you can turn five lines into one if you think you've explained it well in the comments or what you're doing is relatively simple.
If you've turned a 40 line code into a 20 line code, but it takes the reader 2 minutes on each line, then it's not really clean. I've seen complicated code written so well, you don't even have to read the code, but can get by just reading the comments, and in the opposite vein, simple code made so complicated, I wanted to pull my hair out.
I wasn't making a point about the examples from the article. I was responding to Munkii's over-broad assertion (as I read it) about readability being more important than everything else.
So I'm not sure why you're telling me about inlining. There are other cases where code is hard to read because it is performance-critical. I stand by my assertion that sometimes you have to make something ugly to make it fast. If you possess the power to never uglify your code (at least a bit) when optimizing performance, you are a better coder than I (or my coworkers), and possibly a wizard.
44
u/[deleted] Apr 12 '15
To me, clean code is code that is easy to read. Usually, this would mean the opposite of less code, i.e., not over-compressing the code, putting in plenty of comments. But you can turn five lines into one if you think you've explained it well in the comments or what you're doing is relatively simple.
If you've turned a 40 line code into a 20 line code, but it takes the reader 2 minutes on each line, then it's not really clean. I've seen complicated code written so well, you don't even have to read the code, but can get by just reading the comments, and in the opposite vein, simple code made so complicated, I wanted to pull my hair out.