3 ms·
My take: 1. Avoid overly long and complex condition expressions - break them up for readability. 2. If a part of a long expression has obvious meaning, assign
by einpoklum 4y ago
My take:
1. Avoid overly long and complex condition expressions - break them up for readability.
2. If a part of a long expression has obvious meaning, assign it to a temporary (probably saving a comment); if it doesn't, break a line after it. I don't like assigning variables with arbitrary names that simply duplicate the expression calculating them.
3. `true` and `false` are magic numbers. Calling `my_function(my_data, false)` is quite the hazard in my view: It makes the reader rather likely to fail to notice the exact semantics. I would expect, say,
enum : bool { dont_save_copy = false, save_copy_to_file = true };
my_function(myData, dont_save_copy)
4. This is relevant to almost any language! Even functional ones, where you would be encouraged to use "let" or "with" instead of super-complicated unbroken expressions. If you're writing APL though... you need super-memory and a discipline of steel :-)