2 ms·
Only for globals or where you really, really need it. For locals and lambdas, I try to use 1 or 2 char vars. Usually the first letter of whatever the type is. X
by MichaelGG 10y ago
Only for globals or where you really, really need it. For locals and lambdas, I try to use 1 or 2 char vars. Usually the first letter of whatever the type is. XmlNode -> xn. Event -> e. Longer if needed, but hopefully that's rare.
Really long names in functions just make reading harder. I am not sure it makes things actually clearer. Can someone understand the code without actually understanding the function? Can they make an edit?
- runesoerensen 10y agoHow are `xn` and `e` more readable/understandable than for instance `xmlNode` and `event`?
- davelnewton 10y agoI don't think OP is claiming they're more readable in general, but for tiny scopes where they're ghosted in a line or two I'm not sure I see the point in being super-descriptive, either. (Although I wouldn't use `xn`, I'd use `node`. `e` for `event` is fine.)
- runesoerensen 10y agoHe wrote "For locals and lambdas", which includes more than just tiny scopes (where I agree that short variable names can be appropriate and improve readability e.g. `xmlNodes.Select(x => x.Value)`)