3 ms·
Just as taste is a subjective thing as is often hard to articulate... I think my biggest complaint about that code is that I had to read all of it to make sure
by tonyarkles 10y ago
Just as taste is a subjective thing as is often hard to articulate... I think my biggest complaint about that code is that I had to read all of it to make sure there weren't other cases where the card gets eaten. And try to follow what was going on.
Taste-wise, an easy fix for this is to do early exits. Instead of nesting, you could easily do (I'm on mobile so no fancy formatting):
If card is not valid: return message
If user is not valid: eat card; return
Etc
Now that's my personal taste. It makes it way simpler to quickly skim and understand what's going on.