I support the code for the mathematical algorithm that came from the book, with links in the comments. Is it better to have variable names that describe what the variables represent, or do the variables correspond to what is in the book?
For a simple example, I can see this code that reflects a variable in a book.
A_c = v*v/r
I could rewrite it as
centripetal_acceleration = velocity*velocity/radius
The advantage of the latter is that anyone looking at the code can understand this. However, the advantage of the first is that it is easier to compare the code with what is in the book. I can do this to double check the implementation of the algorithms, or I can add additional calculations.
Maybe I'm thinking too much about it and should just use comments to describe variables. However, I prefer self-documenting code (use the names of descriptive variables instead of adding comments to describe what they are), but perhaps this is the case when the comments are very useful.
I know this question may be subjective, but I was wondering if anyone has guidelines for making a decision or have links to guidelines for a mathematical coding algorithm.
source
share