Just Say ‘A Class Implements

a Data Type’

I agree with Chenglie Hu’s “ Viewpoint” “Just Say ‘A Class Defines a Data Type’” (Mar. 2008) that data types are of central importance in computer science and should be emphasized throughout the curriculum. In CS 2, I always dedicate a good number of lectures to abstract data types and their ( algebraic) specification. Some students are initially resistant, but eventually most recognize that an “interface” in Java’s sense is not enough to explain what, say, a priority queue is, whereas an “implementation” (or “class”) provides too much detail.

PAUL WA TSON

Motivating ADTs by examining “basic types” in a more abstract light, separated from their ( accidental) properties in a given language or machine, seems to work well. One of the few advantages of C++ over Java is that “user-defined types” can be made to look exactly like “basic types,” thus allowing for continuity.

A word of caution: Despite the educational and practical value of ADTs, an emphasis on them may be seen as “too theoretical” by some. If you indeed consider this route, be prepared for the inevitable discussions.

Finally, I offer three minor disagreements with Hu: Algorithms and data types are a “holistic whole,” so there’s no need to separate them; variables are instances of an ADT; and just say “a class implements a data type.”

PETER H. FROEHLICH

Baltimore, MD

Chenglie Hu’s point about “toy” objects in his “Viewpoint” (Mar. 2008) resonated with me. At the time I graduated from the U.S. Navy’s Nuclear Power Program in 1983, the classroom part of the course was a six-month cram session of 76-hour (or more) weeks. We spent the first three learning or reviewing a classic high school sci-

ence and math curriculum, then moved into the physics, thermodynamics, chemistry, and mechanical engineering needed for us to understand and operate the systems comprising a nuclear-reactor propulsion environment. The only way to coherently tie all these topics together while moving this quickly was to use real data and real examples from working reactors. From beginning to end, we were exposed to real-world examples in our studies.

Even with real data, 75% of the people entering the program did not complete it. I can’t imagine even trying if we had only toy data and examples. I encourage all programmers and educators to weigh the benefits of using real-world examples in their courses in the interests of allowing a quicker and more complete understanding of the material.

JACK CAIN

References:

Archives