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

This image shows six different ways to write a simple function, getOddness(): https://seeinglogic.com/posts/visual-readability-patterns/6-...

Personally, my normal style is getOddness2(). I try to never have an expression in my return statement -- only return a literal, local variable, or class data member. Why do I choose getOddness2()? It is so easy to debug. When I write code, I am mostly thinking about difficult to debug -- control flow and local variables.

I would like to hear about other people's style and why they choose it.

Related: Does Google Code style guidelines (perhaps the most famous of such guidelines on the Interwebs) have anything to say about which version of getOddness() is best/recommended?



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

Search: