3 ms·
Your example is artificially designed to make your point, but imagine a case like this: # Add the left & right margins width = calculatedWidth + 1 + 1 The
by teo_zero 4y ago
Your example is artificially designed to make your point, but imagine a case like this:
# Add the left & right margins
width = calculatedWidth + 1 + 1
The "+1+1" might indeed be more readable than "+2".
- alpaca128 4y agoYes, I sometimes do that as well to signal a part that's non-obvious or easy to overlook. Ideally with a little comment for the reason. Same with my (admittedly rather dirty) openSCAD designs, where I like to explicitly add tolerances to the measurements while keeping them separate, e.g. `width = 34 + 0.25;`. Especially because tolerances often have to be tweaked a couple times.
- 29athrowaway 4y agoYou miss the point. The problem are not arithmetic operations.
- teo_zero 4y agoSorry if I've misunderstood your post. The parent article was about replacing dense code with more lines of simpler syntax. I assumed you were in the shorter-is-better camp and willing to prove it with your example, where shorter undoubtedly is better. I found your example far stretched, and designed another case using your material (arithmetic operations) but applying only 2 repetitions, much in line with the spirit of the fine article. I hope I managed to show that, although we can agree that "very very longer is worse", this not always implies "shorter is better".