The more I advance in coding the more I tend to hang out with people with more advanced knowledge. Some of the things they tell me is that flags should be reduced to a minimum as it can create spaghetti code.
Judging from my own coding style I can only confirm this:
var active, isWalking, otherState, breathing, flag, flag, flag and so on;
if (keyPressed) {
isWalking = true;
} else {
isWalking = false;
}
if (isWalking && something2) {
active = true;
} else {
active = false;
}
if (active && click) {
otherState = "jump"
}
if (otherState == "jump") {
breakting = "heavy";
}
It is nice and readable but how do I reduce the number of flags used? What are some best practices?