Week 10

Week 10 Plan

  • Oct 30 – turtle basics
    • Activity 1: make a square with 4 moves and 3 turns.
    • Activity 2: make a square with a loop.
    • Activity 3: make a random color and width on each side of the square.
    • Activity 4: make an octagon or some other polyhedral
  • Nov 1 – secrets of programming
    • turtles with forces or tendencies
    • Activity 1: steer a turtle with a sinusioid.
    • Activity 2: steer a turtle with Perlin noise.
  • Nov 3 – spirals
    • Activity 1: make a spiral by turn, move, repeat.
    • Activity 2: make a spiral by go out, mark, turn around, come back, rotate, repeat.
  • Turtle Graphics page with documentation.

    Turtle Graphics

    See Turtle Graphics under Instructions Menu

    Secrets of Programming

    Specifications

    Every program should have two parts:

  1. A specification, usually informal text in comments, that explains how and why your program works.
  2. The implementation, i.e. the code.

Rather than making the code solve your problem directly, you should focus on making the code do exactly what your specification says it does. As you work, you will find both errors in the specification and in the implementation. The problem with writing code directly with English descriptions is that code is too detailed and hard to reason about. Having two perspectives on the problem and its solution is invaluable.

Incremental Development

Start with a simple program that works and modify it incrementally, adding new features one-at-a-time until your program is finished. Test at every step. If you encounter a problem, it will almost always be related to the last change you made, which is both small and fresh in your mind, and therefore quick and easy to fix.

Rubine’s Rule

If you find a bug, fix it. (Due to Dean Rubine, programmer extraordinaire.) Programmers often think they can pursue one problem while ignoring other “unrelated” problems. Those “unrelated” problems are often critical and your misunderstanding of them will cause all sorts of confusion. To avoid getting nailed by your own misundertanding: if you find a bug, fix it.

Write Quality Code

Do not tolerate sloppy code, especially if it is yours. In the words of a former student, you should love yourself and therefore love your code, which is yet another manifestation of who you are. In a way, good code, good art, and good writing are all part of being the person you want to be. Making things of quality may seem more difficult, but if you develop a strong habit of being careful, demanding, critical and exacting, you will find that it actually makes coding easier.