Building Abstractions with Data

  • In Chapter 1 we wrote procedures that operated on simple numerical data.
  • In this chapter we are going to look at more complex data.

Just as the ability to define procedures enables us to deal with processes at a higher conceptual level than that of primitive operations of the language, the ability to construct compound data objects enables us to deal with data at a higher conceptual level than that of primitive data objects of the language.

  • Consider functions dealing with rational numbers: only being able to return one number is awkward. This is where compound data objects become useful.
  • Data abstraction separates representation from use. It enables us to construct abstraction barriers between different parts of the program.