2 ms·
> The named booleans suggested here help adding clarity, but more often than not they'll end up being single-use (const) variables that just paraphrase their de
by monocasa 4y ago
> The named booleans suggested here help adding clarity, but more often than not they'll end up being single-use (const) variables that just paraphrase their definitions. In these cases I'd rather avoid introducing a variable, and rely in comments if I really need to explain something.
Interesting. With the same axioms I come to the opposite conclusion. That comments are to be avoided except when strictly necessary, and giving names to concepts via intermediate const variables is one of the best weapons in that fight. Ie. make your code read as close to what the comment would be (but simply via naming) makes it very clear when the names no longer match the behavior, in contrast to comments which have a tendency to bit rot.
- Sai_ 4y agoThis is what I used to love about Obj-C - idiomatically written Obj-C code was always so much easier to read and understand without needing comments.