3 ms·
How about just "status" for the return code var name? It should be readily apparent that the var is "my" (the routine's) status [code].
by Roboprog 10y ago
How about just "status" for the return code var name? It should be readily apparent that the var is "my" (the routine's) status [code].
- Niksko 10y agoOk, the 'function' part is not useful. And perhaps C was a bad example. Let's say it's Python now, and for some reason I'm still returning 0, -1 or -2. Then 'statusCode' would be a good name for the variable I guess. The code part indicates that it's a codified version of the status. The smarter way might be to just return a status object or something, in which case perhaps 'statusObject' is better? Not sure. I guess one thing I took away from the article is that it would be nice to be able to encode _how_ the data is being returned in the name of the return value. This saves me going and finding when the variable was created to get its type, or when the variable was assigned to.
- Roboprog 10y agoI'm OK with the "one word" parameter / return value names, in part, I guess, because I'm also a big proponent of a "pro forma" comment banner for every routine. For simple things, the comment can be a one-liner ("Return thing X"), but otherwise, explain each param and the return value. Now, if the internal variables require a "data dictionary" level set of comments, that's another matter. Something is (usually) wrong in that case.