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

IMO, things evolve when a function grows.

First, you have “a hundred lines of code”

Then, you add white space to separate somewhat independent parts.

Then, you add comments that describe those parts.

Then, you notice some of these comments aren’t good, and refactor the code a bit and tweak the comments to make them good comments.

Once you’re there, refactoring the parts into decent functions is just a further iteration. It may be hard work, though, as it often means introducing new types that must be given good names.

Where you stop with this is a bit a matter of taste, but also depends on project size, development team size, (expected) longevity of the code base, etc.



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

Search: