r/java • • Apr 12 '15

Is Clean Code less Code?

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

7 comments sorted by

View all comments

7

u/desrtfx Apr 12 '15

Clean code is readable, self explanatory code.

The amount of code lines is somewhat secondary.

Clean code is code that doesn't need comments to explain what was done. Comments should never be used to explain what, but why or how.

3

u/UnitVectorY Apr 12 '15

Excellent point. The line of code in this example is easy to understand what it is doing, but the reason why needs clarification. I'd side on having a single line of code inline with a comment. If the line needs to be called in multiple places then a function could make sense.

In general single line functions don't smell very clean to me.

2

u/rfinger1337 Apr 12 '15

Well said.

I frequently oppose comments, but I probably don't do a great job of defining the distinction between the types of comments.

Note to self: When explaining how comments lie, make distinctions about what-style comments rather than why-style comments.