Re:Storing hundreds of millions of simple key-value pairs in...
by cperciva on Tuesday November 01, 2011 @06:44PM
(#3184507)
There's a tradeoff in the naming of functions. If you have lots of functions named functionWhoseNameMakesItVeryClearExactlyWhatItDoesToItsParameters(), your code will end up being hard to read simply by virtue of the volume of text people need to read through. I prefer to have gist_of_functionality() with more details easily accessible in an obviously-placed comment.
Re:Storing hundreds of millions of simple key-value pairs in...
by mbreese on Tuesday November 01, 2011 @05:50PM
(#3184299)
A function may have the perfect name at the time you wrote it. It may make perfect sense within the context that you initially conceived of it. However, after some time away from it, when you're trying to mentally rebuild that context, it may make as much sense as def foo().
Good naming is important, but you also have to know the context, which is more difficult to remember.
Re:Storing hundreds of millions of simple key-value pairs in...
by ryanpetrich on Tuesday November 01, 2011 @10:33PM
(#3185119)
If it only makes sense within the context it was conceived under, that's not a perfect name. A function name should make sense for someone with understanding of the domain, but no understanding of the code. When that's not possible, comments definitely help.
Re:Storing hundreds of millions of simple key-value pairs in...
by sbov on Tuesday November 01, 2011 @07:24PM
(#3184621)
I don't understand how you can really have a function name that properly says what it does without it being overly long.
In particular, function names seem to focus more on expressing the postcondition but make no mention of preconditions, exceptions, error conditions - all which also need to be known when figuring out what a function does.
In other words, strlen becomes strlen_segfaultifstrnull. You could theoretically encode that in the parameter name, but it becomes even messier when you have functions that raise exceptions. And now instead of long function names, all your functions are using long variable names that serve no purpose other than documenting said error conditions.
I think function and variable naming is the one of the most important aspects of programming. Without good naming, you can easy double the amount of time it takes to edit and extend functionality.