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:
- Control structures
- Use of library routines, especially those taking parameters
- Designing and implementing functions
- Decomposition and code re-use
We have traditionally had good results using a graphics program for this niche. I attribute this success to several reasons:
- Graphics generally appeal to the students
- Can easily scale the assignment difficulty
- Visual output easier to debug
- Repetition can be made obvious
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
- It has obvious intermediate steps to motivate incremental development: working on individual shapes, building up one block at a time, and assembling them all together. The student can experiment with both top-down and bottom-up strategies in tackling the problem.
- The testing and debugging is rather straight-forward. The first large project in CS1 can cause frustration for our students who haven't yet amassed much debugging experience, yet this has not been as much a problem for quilt given the direct correlation between bugs and their visual result. Once the student's picture matches the goal, they know they have satisfied the functionality requirements.
- There are a lot of interesting design issues. What kind of naming conventions should you use for your routines and parameters? How far should you decompose? How can you unify the similar but not identical elements? There is much opportunity to have meaningful discussions with the students about the various tradeoffs and emphasize the importance of considering these issues.
- The content seems general appealing, especially to the creative, right-brain type who might be turned off by a more mathematical/engineering project. We leave one block unspecified in the requirements as their "creativity block" and encourage them to embellish on the basic blocks as much as they are able. The students are excited by a program with a tangible result and it often inspires them to go well beyond the basic requirements, we have many beautiful and extraordinary versions submitted by the more advanced students.
- The assignment is easily adapted. It is really just a platform for delivering a graphics assignment, with total freedom to design the individual blocks to meet your needs. Want to empahsize more or less math? Need to change the blocks to fit the features of your graphics library? Have to shorten or lengthen the assignment this quarter for time constraints? Want to assign a team or class project where different student supply different blocks? Need to change the blocks to avoid problems with plagiarism from previous quarters? The flexibility you seek is there.
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.
Resources
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
mailto: zelenski@cs.stanford.edu
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.