Train students to draw pictures of code traces through namespaces, objects and function calls because the benefits of drawing these processes helps them avoid common mistakes.

  • Tell students that, as beginner programmers, it is much easier to make mistakes if they do all the work in their head.
    • Drawing things out on paper can help them avoid many of these early mistakes.
    • This deliberate practice at the beginning of their programming career will make it easier for them to do work in their heads further down the line.
  • If you want students to draw pictures to improve their understanding of what is happening in a segment of code, it is not sufficient to simply encourage them.
    • If students don’t follow through, there will be no benefit.
  • Discover ways to go beyond just encouraging participation in this event by using different techniques. Consider the following:
    • In-class exercises or homework problems where students are asked to draw out the execution of complex code.
      • Demonstrate the solution with drawings of your own.
    • In office hours, have students draw out the code execution of a particular segment of code.
      • This makes it easier to gauge their level of understanding.
  • The following are concepts where drawing is particularly useful:
    • updating of a stack in a recursive call,
    • interaction of data being passed through functions and different namespaces,
    • explaining what happens when shallow vs deep copy occurs on objects containing mutable types.
  • Python Tutor is a very useful tool to help students check their work and visualize code execution. However, it should not take the place of the work students need to do in order to visualize code themselves.

The opinions expressed are those of the Suzanne Matthews and not necessarily the position of the Army or DoD.

More about this tip

External Source

Interview with Suzanne Matthews