Book - 4.4) DataStructures - Layers Abstraction

Layers of Abstraction

Having seen several ways to represent values ( using types) and organize these values (using lists and dictionaries), we now want to relate these ideas to the central concept of abstraction. The challenge in representing a realistic abstraction is how to organize the values of the abstraction so that the representation can be understood by the person developing the algorithm and still possible for the computer to perform the operations of which it is capable. We will begin with a simple example to illustrate the process by which the challenge can be met and then consider more complicated cases.

We have seen earlier that an abstraction can be visually represented by a table where the label of each column is the name of a property and each row in the table has the values for each property for a given instance.

The values of individual information properties can be represented using an appropriate type. For example, to represent the temperature in a specific city we simply need a whole number. The humidity and wind values can also be represented by whole numbers. The name of the city can be represented by a character string.

To represent the multiple and related values for a given instance a data structure, such as a list or dictionary, is needed. The data structure is simple a way to organize the values representing an abstraction so that the relationship among the values is maintained in a meaningful way.

Because the world is a complex place the abstractions that we create of complex entities are correspondingly complex. In our abstraction because each aspect of the complex entity is represented by an information property. The more aspects there are, the more properties must be part of the abstraction. Despite the fact that abstractions are simplifications of the real world, they can nonetheless be complicated enough that the techniques we have developed so far are not adequate.

One of the ways that people use to organize complexity into manageable pieces is by the use of hierarchy. In a hierarchy the single entity being modelled is defined in terms of a small set of top level properties. Each of these top level properties may themselves consist of some number of second level properties. Second level properties may consist of third level properties, and so on. This process continues until all of the properties are represented by basic types.

A hierarchy representing aspects of a person is shown in the following figure. Here, the person is defined in terms of three top level properties: a name, a birthday, and an address. The name property itself consists of a first name, a middle initial, and a last name. The birthday property consists of a month, a day, and a year. The address property consists of a street address, a city, a state abbreviation, and a zip code. Each of these lowest level properties can be represented directly by simple types. For example, a month is a simple character string, a day is a simple whole number (type int), etc.

Abstraction-Hierarchy-Example.png

An Example of a Hierarchical Description