Hacker News new | past | comments | ask | show | jobs | submit login

>Needing to bounce all over the codebase to figure out what those little functions are actually doing is hugely distracting while I'm trying to read.

Ideally those functions should be named such that their jobs are fairly obvious.




Sure, but that totally depends on context. A function called `renderFooter()` is great, even if its just 1 line. I know exactly what thats going to do.

But a call to `setImpulse(spaceship, 0, somevar)` might just set member variables ximpulse and yimpulse, or it might make a bunch of calls to the physics engine, or both, or something else entirely. If I'm trying to understand some code that calls setImpulse I'll probably end up looking it up just to be sure. So in that case, if it does just set the member variables I'd prefer to just write `spaceship.ximpulse = 0; spaceship.yimpulse = somevar;`.

Same thing, but less work to read.


It's the difference between reading code to get an intuition of what happens, and reading code to debug an issue.

For the first, well named single line functions are great. For the second, they require a lot of jumping around.




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

Search: