logoalt Hacker News

userbinatortoday at 6:04 AM3 repliesview on HN

Limit function length: Keep functions concise, ideally under 70 lines. Shorter functions are easier to understand, test, and debug.

The usual BS... yes, shorter functions are easier to understand by themselves but what matters, especially when debugging, is how the whole system works.

Edit: care to refute? Several decades of experience has shown me what happens. I'm surprised this crap is still being peddled.


Replies

puchatektoday at 6:29 AM

This one, like some others in this style guide, can also be found in Clean Code. Not sure why you feel the need to call it "BS". Nobody is saying that your 75 line function is bad.

It's a reasonable guideline. Juniors won't do this automagically.

show 3 replies
stousettoday at 6:17 AM

It’s a lot easier to understand entire systems when they’re composed of small, pure, straightforward parts.

show 1 reply
danparsonsontoday at 6:16 AM

The low level stuff is also important.