4 ms·
OK but which is more readable ... (I know it's a bit silly, I juts made up names) } else if (D >= (1 << 14) || M == 0 || (x + 3) + M > 34) { } else if (Direct
by nicky0 10y ago
OK but which is more readable ... (I know it's a bit silly, I juts made up names)
} else if (D >= (1 << 14) || M == 0 || (x + 3) + M > 34) {
} else if (DirectWeightingFactor >= HUYGENS_LIMIT || MariachiBand == 0 || (xylemNonce + STANDARD_PZSH_INCREMENT) + MariachiBand > SWIM_RATE_B) {
I guess your opinion differs to mine. I like the one that looks like math.
- pilif 10y agoWhat about a middle ground? } else if (D >= HUYGENS_LIMIT || M == 0 || (x+3)+M > SWIM_RATE_B)
- Ralfp 10y agoAnd then somebody else will write angry hackernews comment how code is abysmal because it mixes in single char names. ;)
- randlet 10y agoThe more verbose name is infinitely more preferable to me. If I am tasked one day with doing some maintenance on this code and have never encountered it then at least I have a hint that I should be researching the aquatic properties of mariachi bands.
- dietrichepp 10y agoI would have a hard time with that, the long names hide the structure. Know your audience. Do you expect future maintainers for your compression algorithm to be people with knowledge of compression algorithms? Or do you expect them to be random programmers off the street?
- josephg 10y agoAs someone who's written and maintained code like this, in my experience the heavy algorithmic parts themselves usually requires almost no maintenance. Its the surrounding code - the API endpoints, makefiles and test suites that need to be modernized every few years. Algorithms like this are written, then used, then better algorithms are written from scratch. Code like this also usually can't be edited piecemeal. Any change requires reloading the entire algorithm into your head before a single line is changed. And as others have mentioned, the normal way to do that is to read the paper. .. And if you do that, the paper's naming convention becomes the natural way to express the algorithm.
- stinos 10y agoI'd like the one where this whole thing is put in a function with a name describing what it does, no matter whether the math-like one or the one with long names is used. that I'd consider readable. And any sane compiler inlines it anyway.