[Index of Lectures]

[ L01 L02 L03 L04 L05 L06 L07 L08 L09 L10 L11 L12 L13 L14 L15 L16 L17 L18 L19 L20 L21 L22 L23 ]

Lecture 05—Compound data, extending an existing world program

Before Lecture

You are now expected to be able to solve problems from the entirety of module 3a and the first four sections of 3b Compound Data. That is Module Overview, define-struct, Compound Data definitions and the Practice problems as you need to.

During Lecture

Writing a new program from scratch is fun, but programmers actually spend most of their time improving existing programs. Remember, any program that someone actually uses constantly requires revisions—to fix existing functionality, to add new functionality, or just to adapt to changes in surrounding programs. You can revise existing programs reliably by following the same systematic design process used to develop them in the first place. (Or by imposing a systematic revision process onto a clearly unsystematically designed program, but that is beyond scope for now.)

By the end of the lecture—including the post-lecture work—you should be able to:

In this lecture we will continue working on the spider world program. Here are the starters for today:

After Lecture

Today was the most difficult work we have done - congratulations! The design problem we worked through used pretty much every single thing we have covered so far in the course: all the recipes, big-bang, compound-data, revising an existing program. Everything!

If it felt like a lot that's because it was a lot.

Here are the solutions for this lecture:

We started with a working world program, changed the requirements so that it needed a compound world state definition, and then had to revise and extend the program. The key is to trust the recipes to tell you where to focus your attention. Whenever you are unsure what to do, ask yourself "what recipe am I in, and what does it say I should do now?" Then you will not get confused about where to focus, and you can always focus on a small sub-problem.

Trust the recipes.

To Review

To practice what you learned today we suggest you finish up (or rework!) the spider problem, starting from v2. When you are doing tock spend a long time on the examples. Use paper to work them out! In the key handler pay particular attention to the template. Rather than templating it from Spider, we template it according to KeyEvent using the large enumeration rule. The Improving a World Program—Add Key Handler section goes into this in some detail.

A very good way to review this material--and really to review the entire course so far--is to work through the HtDW With Compound Data (aka Cowabunga) video. By work through we mean sit there with Dr Racket and a pad of paper and do the whole design in parallel with the video: start the video, watch a little, pause it and then try to get ahead of it on your own, restart it, etc. You won't get much out of just watching the video; in order to effectively practice, you must work through the problem on your own.

If you had trouble with today's problem then you probably should repeat that entire design process before moving on to Cowabunga. You can go to instructor office hours or TA hours in the DLC (see the course web page) for additional help.

Be sure to complete the before lecture section of Lecture 6 before that lecture.