Abstract

In case you missed the signs, design patterns [2] have suddenly become a core programming topic. The Computing Curricula 2001 [1] includes the topic as a major part of SE1 "software design," and in a recent survey [4] software practitioners ranked "software design and patterns" as one of the areas of knowledge they consider most important to their work.Teaching design patterns, however, is not so easy. Patterns need to be studied in the context of a software design project; to do otherwise renders the topic asomatous. We have met with some success in using "musical composition" to teach a number of standard design patterns, including Composite, Decorator, Visitor, and Factory. The idea of musical composition comes from Paul Hudak's Haskore system [3].The project centers on the design of a "musical object," by which we mean either a note (with a pitch and duration), a rest (having just a duration), or a combination of musical objects. The combinations can be contemporaneous (as for a chord), or sequential (like a scale). The two primitive music types together with the combinators come together using the Composite inheritance pattern. Decorators can then be added to describe tempo changes (the scaling of the duration of all parts of a musical object), pitch transpositions, and to assign different instruments to parts of a composition.With the descriptive part of the system so formed, a Visitor can be used to traverse the musical tree and generate a linear sequence of "musical events," which can then be written as type 1 MIDI files for playback on most standard PC equipment. As well as learning about design patterns, students are given the opportunity to try their hand at transcription or composition. Some examples of their work can be found at http://www.cs.auckland.ac.nz/courses/ compsci360fc/ archive/1999/Ass2/PickOfTheBest/.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call