The Sampler Quilt

This is an early CS1 assignment that asks the students write a program that draws a "sampler quilt" using a simple graphics library. Our sampler quilt is made up of five different blocks, each with its own theme, while featuring common elements. Each block is repeated five times and all are arranged to form the entire quilt. The result shown here is an attractive pattern of interesting shapes and colors.

The assignment niche

We use this program fairly early in CS1. After the first few weeks on syntax, variables, and program flow, we assign our first "large" complete program. This assignment is mostly focused on: We have traditionally had good results using a graphics program for this niche. I attribute this success to several reasons: My first few attempts at building a nifty graphics assignment were to create some scene, such as the the Manhattan skyline, a boat regatta, or a pasture full of sheep (don't ask...). Each would have a lot of repeated elements with variations in location/size/color to give the students motivation to design general-purpose routines using parameters. Although these ideas worked okay, the assignments did feel a bit contrived and rigid. When the idea of the sampler quilt came to me, I was really excited about its ability to motivate the repetition while providing a lot of flexibility in the design. I did appropriate one actual quilt block (the "log cabin" of nested frames), but just made up the rest to suit my fancy.

Why I like the quilt assignment

The magic quilt screensaver

We also have an accelerated CS1&2 course that is designed for students with more experience. These students tend to have a lot of technical skills, but often are lacking a sense of style. The quilt is an excellent opportunity to stress the importance of decomposition and code re-use right from the start.

For this course, I assign a jazzed-up version of the quilt as their first assignment. To give these students some extra challenge, I have them bring the quilt to life as a screen-saver (an idea I borrowed from Marissa Meyer, a former TA). They build the blocks from the sampler quilt, but then go on to bounce them around on the screen, zoom them in and out, or flash them in different colors. One wonderful benefit of this was to remove the temptation to hard-code magic numbers into the blocks, since each block needs to be able to be arbitarily sized and placed.


Contact info

Let me know if you find this page useful or have additional ideas to contribute. I'd love to hear from you!

Julie Zelenski
Department of Computer Science
Stanford University

This page in support Nick Parlante's ACM SIGCSE Symposia 2001 Panel on Nifty Assignments. Other nifty assignments are available!

Last updated: July 12, 2001.