McConnell_2004_CH15_UsingConditionals Flashcards
A conditional is a statement that…?
controls the execution of other statements.
Execution of other statements is …?
“condition” on statements such as if, else, case, and switch.
(Although it makes sense logically to refer to loop controls such as while and for as conditionals too, by convention they’ve been treated separately.)
What order should conditional code be written…?
?????
What is the most common cause of off-by-one errors in conditional code?
Using > instead of >= or < instead of <= is analogous to making an off-by-one error in accessing an array or computing a loop index. In a loop, think through the end points to avoid an off-by-one error. In a conditional statement, think through the equals case to avoid one.
Why is it bad practice to mix nominal cases and error cases?
It makes code hard to follow when nominal and error cases are all mixed together.
It makes it hard to find a path that is normally taken through the code. In addition, because the error conditions are sometimes processed in the if clause rather than the else clause, it’s hard to figure out which if test the normal case goes with.
What are the three common mistakes with else clauses?
??????
How can elseIf chains be used to replace case statements? 362
????
What is the effect of the ‘then’ keyword in JADE…?
?????
List the three Boolean Binary Operators in Jade? For each provide a definition…?
????
List the symbols and names of the six Relational Binary Operators in JADE…?
?????