3 ms·
A nice reminder that skill and raw brainpower are two different things, and the latter can retard development of the former. I worked with many pieces of code
by dkarl 17y ago
A nice reminder that skill and raw brainpower are two different things, and the latter can retard development of the former. I worked with many pieces of code written by one particular coworker of mine who was way too smart for his own good. His code was littered with little formulae like that, repeated again and again throughout a file, and to him it was obvious at a glance what they meant. It was also easy for him to scan through his code and find errors in these expressions, as easy as it is for you or me to see that "(matthes-js2-line-ending ..." contains a typo. I have no idea how he coped with finding and changing every instance of a formula that needed to be changed. For me it was a slog every time I had to read, change, or debug his code.
P.S. The most frequent and flagrant was calculating array indices into multi-dimensional arrays in C++. It's so easy to write a simple class that lets you do this:
arr(n1 + i, n2 + j, n3 + k) = calc_foo(i, j, k);
instead of this:
arr[n3 + k + (n2 + j) * (nz + (n1 + i) * ny)] = calc_foo(i, j, k);
- swolchok 17y ago1) That's not a multi-dimensional array, that's a one-dimensional array simulating a multi-dimensional array. 2) Why not arr[n1 + i][n2 + j][n3 + j] = calc_foo(i,j,k) ? It's a bit more work to write the proxy classes, but a Sufficiently Smart Compiler(TM) can make that all go away for you.