McConnell_2004_CH15_UsingConditionals Flashcards

1
Q

A conditional is a statement that…?

A

controls the execution of other statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Execution of other statements is …?

A

“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.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What order should conditional code be written…?

A

?????

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the most common cause of off-by-one errors in conditional code?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is it bad practice to mix nominal cases and error cases?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the three common mistakes with else clauses?

A

??????

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can elseIf chains be used to replace case statements? 362

A

????

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the effect of the ‘then’ keyword in JADE…?

A

?????

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

List the three Boolean Binary Operators in Jade? For each provide a definition…?

A

????

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

List the symbols and names of the six Relational Binary Operators in JADE…?

A

?????

How well did you know this?
1
Not at all
2
3
4
5
Perfectly