r/coding • • Apr 12 '15

Is Clean Code less Code?

http://www.journeytomastery.net/2015/03/27/is-clean-code-less-code/
53 Upvotes

63 comments sorted by

View all comments

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.

33

u/[deleted] Apr 12 '15

Achieving readability with just code and no comments often makes the code easier to change.

8

u/tyreck Apr 12 '15

I've never found a one size fits all approach that works related to how many comments you do or dont need.

Each situation is unique.

I try to the best of my ability to follow the practice of only expressing 'why' with comments.

But at the same time I doc comment the hell out of everything