4 ms·
I do not see this as an issue if the comment immediately Precedes the "Clever" section of code. Calculations are the most important part of the code to comment
by bigger_cheese 10y ago
I do not see this as an issue if the comment immediately Precedes the "Clever" section of code.
Calculations are the most important part of the code to comment I'm an Engineer most of the guys I work with have never been formally taught any programming often I see a bunch of code written in Fortran with notoriously short variable names if it wasn't for comment very easy to get lost.
So long as there is a comment saying something like
"Ergun's Equation - Calculates Pressure Drop"
You don't need to follow all the fluid dynamics to know what the code does - at minimum someone reviewing it can google "Ergun's Equation"
You don't need to comment linear Alegbra but at least comment what the code does "//Solve using LU factorization" or similar is sufficient and it beats seeing segments of code like this with no explanation:
r[i] = 1/(pb[i]+t[i]-fr1[i-1]-gr2[i-2]);
u[i] = a[i]-r1[i-1]u[i-1]-r2[i-2]u[i-2];
f = pc[i]+t1[i]-h*r1[i-1];
Edit: It stripped chunks of the above code but you get the idea.
- wangchow 10y agoTrue--sometimes when translating from a mathematical context to programming causes some readability pains! Especially if it's something that takes advantage of multiprocessing to solve the problem.