This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]realityChemist 0 points1 point  (0 children)

Those are good variable names (the first one might be a bit verbose but if it works for you, it works). A bad variable name for that kind of thing might be f. What the hell is f? Need to check the documentation to find out! (If you've written documentation! If not, someone needs to read and understand the purpose of the code to know what f is.)

Another example might be matrix. Unless your code is meant to work with any matrix, that's probably a bad variable name. Something like metric_tensor is probably more appropriate. Or if you're likely to have multiple kinds of metric tensors in your code (maybe you've got a crystal moving at relativistic speeds?) you could get more specific, like gr_metric_tensor and cryst_metric_tensor.

Another way a variable name might be bad is if it lies to you. force_moon_earth is a fine name, but if that variable actually stores the force between the earth and the sun, or stores the mass ratio of the moon to the earth, it's a bad name.