Hacker News new | ask | show | jobs
by abstractspoon 230 days ago
For me, logic is easier to understand when each operand is either on a separate line with a trailing comment, or where each operand is stored in a well named variable.

Any expression with more than 3 operands I rewrite in this way.

I will also reconstruct the expression so that it reads like a line of prose, and where the chain of reasoning reads from left to right, with the most significant operands coming first.

I also use brackets liberally and never rely on the rules of precedence because that reduces the cognitive load.

Sometimes I will also break up the overall expression into named sub-expressions, each with their own comments.