Making if statement conditions into local variables?
I remember a while back I once read someone advise making a variable for any semi-complex if conditions, so that the condition would have a name and be more readable.
I can't seem to find the original source of this advice to look into it more. Are there any downsides to this? Is it something many programmers do? I can see the value in it, but I just wanted see some other opinions on it.
Example (excuse the crappiness of the example, i'm having a hard time thinking of one):
if(foo.isReady && !foo.isRunning)
canStart = foo.isReady && !foo.isRunning if(canStart)
Submitted July 10, 2017 at 09:47PM by paleclaw
via reddit http://ift.tt/2tC3VJj