There are therefore many object models that can be drawn for the same program

There are therefore many object models that can be

This preview shows page 9 - 12 out of 14 pages.

, is 55
Image of page 9
does not retain ordering information or allow duplicates. Note also that no type is inherently ‘abstract’ or ‘concrete’. These notions are relative. A list is abstract with respect to a linked list used to represent it, but concrete with respect to a set it repre- sents. 8.3.1 Abstraction Functions For a particular choice of abstract and concrete type, we can show how the values of the concrete type are interpreted as abstract values using an abstraction function, as explained in an earlier lecture. Remember that the same concrete value can be inter- preted in different ways, so the abstraction function is not determined by the choice of the abstract and concrete types. It’s a record of a design decision, and determines how the code is written for the methods of the abstract data type. In a language without mutable objects, in which we don’t have to worry about sharing, we can think of the abstract and concrete ‘values’ as being just that – values. The abstraction function is then a straightforward mathematical function. Think, for exam- ple, of the various ways in which integers are represented as bitstrings. Each can be described as an abstraction function from bitstring to integer. An encoding that places the least significant bit first, for example, may have a function with mappings such as: A (0000) = 0 A (0001) = 8 A (1001) = 9 56 ArrayList LinkedList List Stack Set implements
Image of page 10
Image of page 11
Image of page 12

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture