Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like to measure things. Like token count, line count, variable count, method parameter count, indentation level and grokking time.

Clean code minimizes these measurements.

To minimize variable count I can use ternary expressions. To minimize indentation level I think carefully about early returns or extracting blocks of code to functions that do nothing if condition is true (early return).

To minimize grokking time, I revisit old code I've written and measure the time it takes me to understand it. It turns out it correlates quite a lot with line, variable, and token count, indentation level :D

Clean code as commonly defined is far away from any measurable metrics. That's why one might say that it does not exist.



Sometimes, (maybe the majority of times) a five liner is clearer than a one liner. I think line count is a terrible metric to use.

Agree about indentation.

Grokking time, and time to make a correct, meaningful change are good metrics.

It’d be interesting to take some of the examples from Clean Code, and rewrite them procedurally, then functionally, etc, and then test which takes the least amount of time for an average developer to understand and modify.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: