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

Thank you! That's really what this post is about :) Facing the loop's body so many times forces you to analyze if something better can be done


In real world, factoring out a function that's only ever used once is usually not the smartest thing to do early. You'd do that if you eg. do TDD.

The article is a false "tip": author explicitely decides not to extract the entire loop body (why?) into a function but only a part of the logic. They've chosen the factoring approach despite no loop, not thanks to it.

Their intrinsic reasoning that led to deciding what to split out would have been more useful, and then we could argue if it was good design tip or not.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: