3 ms·
I'm so happy to see named parameters become more common. They're absolutely critical to writing code that is easy to read. The name of a function tells you wha
by crazygringo 6y ago
I'm so happy to see named parameters become more common.
They're absolutely critical to writing code that is easy to read. The name of a function tells you what it does, arguments equally need names to tell you what they do.
Even if I have a great IDE, I don't want to hover/cursor over the line to see what each argument does, each random "0" or "null" or "1" or whatever. There are also plenty of times I'm viewing code that isn't in an IDE, like a diff.
Obviously they're not always needed, like in functions that take only one or two required obvious parameters.
But otherwise, they can make the intent of a line of code obvious at a glance, and are a huge step toward making code self-documenting.
I just can't believe this is a change that's only picking up now, rather than 20 years ago.
- linux2647 6y agoOn the other hands, many JetBrains IDEs will insert the names of parameters in a function call inline to help identify what passed variable belongs to which parameter. It’s not inserting it in the actual source code, but exists purely in the UI (https://www.jetbrains.com/help/clion/parameter-hints.html https://www.jetbrains.com/help/clion/parameter-hints.html). It’s useful if $LANG doesn’t have named parameters