17
votes
Can I lessen the use of boolean flag variables in this snippet?
Can I lessen the use of boolean flag variables in this snippet?
Consider 1st comparing.
...
10
votes
Can I lessen the use of boolean flag variables in this snippet?
I'm not familiar with unity so, I can't review your code from that perspective. But we can certainly make this code more concise. Let me show you how to get started with refactor this code.
1. Get rid ...
10
votes
Can I lessen the use of boolean flag variables in this snippet?
Each call to handleInputEvents() can set bShow to a new boolean value.
We could approach the display update task by making a
truth table.
...
7
votes
Can I lessen the use of boolean flag variables in this snippet?
Why don't you make button.show() simply do an early exit if the visibility state being passed in is already the same? I'm surprised it doesn't already work this ...
6
votes
Can I lessen the use of boolean flag variables in this snippet?
Since this is tagged unity3d, rather than setting a flag somewhere else in the script, you can just do the following:
...
4
votes
Can I lessen the use of boolean flag variables in this snippet?
You currently have two booleans, capable of representing 4 states (like many other answers have shown with helpful truth tables). But there's actually only 3 cases here: show, hide, and do nothing. If ...
3
votes
Can I lessen the use of boolean flag variables in this snippet?
I think a higher level review of how this whole button thing works.
I want to express a slightly different approach and instead of bShow and ...
2
votes
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
game × 1927python × 493
beginner × 417
java × 410
c++ × 297
javascript × 227
object-oriented × 206
c# × 194
python-3.x × 183
tic-tac-toe × 133
performance × 129
console × 98
playing-cards × 91
c × 71
rock-paper-scissors × 70
hangman × 63
swing × 51
c++11 × 49
random × 49
dice × 47
pygame × 46
snake-game × 45
algorithm × 44
objective-c × 44
community-challenge × 43