Require students to refactor their code while keeping the output of their program exactly the same in order to challenge them to solve problems using a variety of strategies.

  • This is a great technique to get students out of their comfort zones and working on creative problem solving.
  • If students get stuck, provide them with some of the following suggestions for modifying their code:
    • Change for-loops to while-loops.
    • Convert arrays to ArrayLists.
    • Change Strings to character arrays.
  • Tell students that certain data structures or data types cannot be used.
    • This added helps them figure out how to change their code without changing their output.
    • For instance, disallow use of the multiplication (*) operator.
      • This forces students to think about how to implement a multiply() function and get creative.
        • Students can use a for-loop or recursive addition. Give them a chance to figure it out on their own and be creative.

More about this tip

External Source

Interview with Brandon R. Rodriguez