Flag Arguments

Boolean arguments indicate that a function does more than one thing E.g. "if this reason, then do thing 1, else do thing 2" - shows that thing 1 and thing 2 should be their own functions.

void doThing1(int arg1, bool doConditionalThing) {
    statement a;
    statement b;

    if (doConditionalThing) {
        do extra stuff here
    }
}

Could be broken up as

void doThing1(int arg1) {
    statement a;
    statement b;
}
void doExtraStuff() {
    do extra stuff here
}



bj 2019-09-22