4 ms·
> If you have to dig into the details of a function to understand what it does, you have failed to sufficiently explain what the function does through its namin
by quantified 5y ago
> If you have to dig into the details of a function to understand what it does, you have failed to sufficiently explain what the function does through its naming and set of arguments.
Which is often unavoidable, many functions are insufficiently explained by those alone unless you want four-word camelcase monstrosities for names. The code of the function should be right-sized. Size and complexity need to be balanced there- simpler and easier-to-follow is sometimes larger. I work on compilers, query processors and compute engines, cognitive load from the subject domains are bad enough without making the code arbitrarily shaped.
[edit] oh yes, what jzoch says below. Locality helps with taming the network of complexity between functions and data.
[edit] oh no, here come the downvotes!
- CRConrad 5y ago> ...many functions are insufficiently explained by [naming and set of arguments] alone unless you want four-word camelcase monstrosities for names. Come now, is four words really all that "monstrously" much? > The code of the function should be right-sized. Feels like that should go for its name too. > Size and complexity need to be balanced there- simpler and easier-to-follow is sometimes larger. The longer the code, the longer the name?
- quantified 5y agoQuite a bit of sentiment around against long names, I personally am fine with them up to about 30-35 chars or so, then they start to really intrude. Glad you’re not put off by choosing function over form!
- CRConrad 5y agoStretch it to 36, and that is four not-all-that short words, at 4× 9 = 36 letters. Form and function! :-) So it gets monstrous only from five words upwards or so... But still, I think I may by sheer coincidence have come up with a heuristic (that I'm somewhat proud of): The more convoluted the logic = the longer the code needed to express it ==> the longer a name it "deserves".