Consider the two code segments below. Which one is better and Why? If you have any other idea, please do mention. Where can I find answers to coding p
Which on do you think best expresses what the code is trying to say. Which one do you need to work hardest to understand?
I would do this:
bool MyApplication::ReportGenerator::GenerateReport(){
if (isAdmin() && isConditionOne() && isConditionTwo() && isConditionThree()){
return generateReport();
} else {
return false;
}
}
Because:
a). Prefer to say what I want rather than what I don't want b). prefer symmetry, if and else. Clearly all cases covered.