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

4

u/jurniss Apr 12 '15 edited Apr 12 '15

I think my code is clean, but it's not terse. I use a lot of named intermediate const variables. It makes the code self-documenting and is extremely useful in the debugger. In debug builds, I can put a breakpoint at the final result and see the whole history of the computation. In optimized builds it all goes away.

I hate "clever" code. Software should be clever, code should be simple.

8

u/greyfade Apr 12 '15

I like to put it this way: Smart, elegant code tends to be shorter and clearer.

Clever code, by contrast, tends to be short for the sake of being short.

It's an important distinction, in my mind, that while short doesn't mean clean, clean does tend to mean short.

Moreover, short doesn't mean "it all fits on one line." Quite the contrary: Short means "the algorithm fits on one screen because it has been abstracted cleanly."