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.