Using modula-2 to teach data abstraction

  • Authors:
  • J. Mohr

  • Affiliations:
  • Assistant Professor of Computing Science, Camrose Lutheran College, Camrose, Alberta, Canada

  • Venue:
  • ACM SIGCSE Bulletin
  • Year:
  • 1989

Quantified Score

Hi-index 0.01

Visualization

Abstract

The principle of abstraction has assumed a central role in modern software engineering. Most modern textbooks on data structures and algorithms propound the advantages of abstraction as a programming tool. Aho, Hopcroft, and Ullman cite generalization and encapsulation as the two primary advantages of both data and procedural abstraction.Allen Tucker echoes these advantages, defining abstraction as "a conscious process of generalizing a type, procedure, or data structure in such a way that it can serve more purposes than the one for which it was originally designed," and encouraging the packaging of procedures in libraries "to promote their wide utility through generalization."Michael Feldman focuses on the use of abstraction to reduce complexity through information hiding. Encapsulating the details of a representation allows us to "concentrate on the mathematical properties of these entities, their visible structure, and the set of operations that can be performed on them."Robert Kruse shows how distinguishing between a general concept and a particular implementation can clarify code, which often allows us to recognize similiarities between situations which were presumed to be different. He also clearly outlines the various levels at which we solve problems: the abstract (conceptual), data structures (algorithmic), implementation and application (programming) levels.Unfortunately, many students have trouble grasping the concept of abstraction. They see Kruse's hierarchical approach to problem solving as a complication rather than a tool, and have difficulty distinguishing one level from another. (Perhaps this problem is unique to the students I have encountered . . . but I doubt it.)Part of the problem in teaching abstraction is that Pascal, C, and most of the other languages which are widely used in data structures courses do not enforce the use of abstraction. Writing a high-level procedure which uses a lower-level one to do its work seems to be merely a stylistic issue ("The prof wants us to write it this way.") The power of hierarchical structure for controlling complexity is easily overlooked when it just seems to make one's program longer.Modula-2 is one of the more recent languages which support data abstraction by separating the definition of an abstract data type (ADT) from its implementation in separately compiled modules. We have used Modula-2 in our data structures and algorithms class for the past two years, and are converting our introductory programming courses (CS1 and CS2) to Modula-2 beginning this fall. We are convinced that the use of Modula-2 helps students understand data abstraction by experiencing it in a concrete way. In essence, the hierarchical view of a problem is not merely encouraged, but can be enforced by the modular nature of the language.