4 ms·
I believe you've misunderstood this. A function can be very long and do only one thing or very short and do many things. The function: func ManyThing(i int)
by zbobet2012 8y ago
I believe you've misunderstood this. A function can be very long and do only one thing or very short and do many things.
The function:
func ManyThing(i int) int {
fmt.Println(i)
return i+1
}
does two things, and it's two lines long. The function tcp_send_message_locked (https://github.com/torvalds/linux/blob/master/net/ipv4/tcp.c#L1174 https://github.com/torvalds/linux/blob/master/net/ipv4/tcp.c...) does one thing at it's 261 lines long.
Shorter code is _indicative of_ orthogonality (what he asks you to break on)__but_ it is not the same thing.
- networkimprov 8y agoMy critique is of single-caller functions as a documentation device, not shorter functions.
- zbobet2012 8y agoBut he doesn't advocate that... anywhere. He advocates factoring out orthogonal code to get shorter functions.