3 ms·
Instead of cramming the description into a NonPunctuatedFunctionName, just lay down some scoping brackets and write a comment. IDEs are food at folding code.
by srtjstjsj 6y ago
Instead of cramming the description into a NonPunctuatedFunctionName, just lay down some scoping brackets and write a comment.
IDEs are food at folding code.
If the function doesn't need to be called many times, it doesn't need to exist.
- hvidgaard 6y agoCode folding is not good for readability, and creates a significant overhead when reading the code. Even to the point where some static analysis tools default to highlight the use of "regions" as problematic.
- will4274 6y agoJumping up and down in the file while hitting f12 is not good for readability and creates a significant overhead when reading the code. C# finally introduced local functions in a recent version, which will hopefully remind other enterprise-y languages and IDEs that humans are programmed to read lines on a page in order.
- hvidgaard 6y agoIn VS you can press Alt+F12 to peak the function, no need to jump back and forth. Regardless, programming in that way requires that the functions adhere to SRP and a clear name can be written.
- quelsolaar 6y agoI think it can be good to have functions that are only called in one place if they do really well defined things. load_settings, or similar is probably one called on one place, but if it makes sense to have it as a separate function. I prefer clear naming over comments, because comments doesn't "travel" everywhere the named function/type/variable does.
- hvidgaard 6y agoAnd comments needs to be maintained too, which often slips even in PR reviews.
- CuriouslyC 6y agoIf you've got an algorithm or hot loop that's hard to follow because it needs to be, some simplifying functions can keep it from overflowing people's brains, which IMO is the worst overflow error.