CS 220 - Conditionals 2

Review 1

Review 2

Review 3

Refactor Exercise 1

In each case, the programmer attempted to refactor the code twice. One of the refactors is wrong (i.e., the code doesn't behave the same way anymore). Try to identify which refactor is correct and which is wrong. Then step through all three to verify whether A or B was the same as the original.

Original Version

Refactor A

Refactor B

Refactor Exercise 2

In each case, the programmer attempted to refactor the code twice. One of the refactors is wrong (i.e., the code doesn't behave the same way anymore). Try to identify which refactor is correct and which is wrong. Then step through all three to verify whether A or B was the same as the original.

Original Version

Refactor A

Refactor B

Refactor Exercise 3

In each case, the programmer attempted to refactor the code twice. One of the refactors is wrong (i.e., the code doesn't behave the same way anymore). Try to identify which refactor is correct and which is wrong. Then step through all three to verify whether A or B was the same as the original.

Original Version

Refactor A

Refactor B

Refactor Exercise 4

In each case, the programmer attempted to refactor the code twice. One of the refactors is wrong (i.e., the code doesn't behave the same way anymore). Try to identify which refactor is correct and which is wrong. Then step through all three to verify whether A or B was the same as the original.

Original Version

Refactor A

Refactor B

Refactor Exercise 5

In each case, the programmer attempted to refactor the code twice. One of the refactors is wrong (i.e., the code doesn't behave the same way anymore). Try to identify which refactor is correct and which is wrong. Then step through all three to verify whether A or B was the same as the original.

Original Version

Refactor A

Refactor B