4 ms·
This sounds fine if you're the only one using the code. In business, the practice you're describing is needlessly fragile. My opinion is that you shouldn't have
by zapzupnz 7y ago
This sounds fine if you're the only one using the code. In business, the practice you're describing is needlessly fragile. My opinion is that you shouldn't have a home style and a work style — you should just have correct style, something that works equally well in both scenarios.
> If you put meaning into a variable name that you use twice, then you are repeating yourself, which is very bad. Thus, variable names should NEVER be meaningful (except maybe when they are used only once)
I don't understand this sentence at all. My initial interpretation was that one should only use a variable no more than once which seems completely arbitrary. If a variable is only being used once, that's not a variable, that's a constant — but why are constants more deserving of a meaningful name than a variable, something that could (and should) be used multiple times?
After all, if you're declaring a variable but not modifying it or only modifying it once, you should use a constant — but that still doesn't explain why constants are special enough to merit meaningful names.
Further, you haven't narrowed down to when your assertion applies. What about variables in OOP as members of objects? Should mutating members always have nonsense names?
- rswail 7y agoI think this conversation is at cross purposes. In algebra, the statement: x = x + 1 is meaningless. Algebraic variables are not the same as what are effectively names for value storage locations, which is the common meaning of a "variable" in most imperative languages. Of course, with FP, the concept of a mutating variable is frowned upon in general. Mutation is effectively a performance hack.
- zapzupnz 7y agoI suspect you're right that GP was likely talking about a different context but I think that person failed to make that clear, therefore making it seem like their mantra for variable names was universally applicable. Clearly, it isn't.