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

John carmack said much the same and I have been following it ever since. Of course linear code is easier to read, if follows the order of execution. It minimizes eye saccades.

Some code needs to be non-linear for reuse. Then execution is a graph. If you code does not exploit code reuse from a graph structure, do not bother introducing vertexes where a single edge suffices.

http://number-none.com/blow/blog/programming/2014/09/26/carm...



Something Carmack calls out but the OP doesn't is that if you can break out logic with no side effects into its own function that's usually a good idea. I think the left side would have benefited from

  pizza.Toppings = get_pizza_toppings(order.kind)
in this case to keep the mutation of the pizza front and center in the main function here.




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

Search: