Coding katas for computation classes

It’s the middle of the fall semester, just before fall break. That means that I have had just enough time to develop a certain amount of exasperation with student coding habits. From the Friday afternoon before a long weekend, I give you this brief, cathartic set of thoughts.

Programming exercises are katas

Code for a classs supposed to make your brain comfortable going through certain motions, so that you’re better equipped to go through those motions when you face a computation in anger. It should not be a long, mindless slog (though it may be long). If it is, you’re doing it wrong.

Start early

You don’t have to finish early; you just have to understand what you’re facing well enough to plan. Do you basically know how to do the problems? Do you need to read more deeply? Will you want help in office hours?

If you’re continually late, try tracking how much time you think the work will take at the outset, and how much time it actually takes. If you’re surprised by the difference, keep recording it until it sinks in.

Don’t hack mindlessly

Before you start programming your solution, read the prompt. Write a tester. Include some randomly generated test cases, but don’t rely on them alone. Document, at least for yourself, what you assume about the input and output parameters. Look for singularities and pathologies; are they ruled out by design? By all means, pull up a MATLAB prompt and play with some ideas early on, but treat those experiments like the early scrawls you make on a pad. They’re stepping stones, not a thoughtful solution.

Get code working early

Start with the simple case: serial, unoptimized, trivial code. Use existing building blocks where possible. Find your mistakes as soon as possible after you’ve made them. Don’t wait until after you’ve written the entire program. That way lies madness, or at least bad karma.

Find a friend

Ideally, find a friend who is going through what you’re going through. Talk, away from the computer.

Ideally, also find a patient friend who has no idea about computing. Find a way to tell that friend why your problem is cool or challenging. If your friend suggests you go get coffee or tea or something instead, accept – if time permits.

Comments

blog comments powered by Disqus
Fork me on GitHub