![]() |
CS 15-212: Fundamental Structures of Computer Science II |
We continue with signatures and structures by discussing views and data abstraction. Opaque signature ascription is generally recommended, to specify precisely which operations can be carried out on a type. Transparent ascription may be appropriate, however, if the signature is intended only to specify the minimum requirements that a structure must satisfy.
A representation invariant is a condition imposed on an implementation of a type that must be preserved by all of the operations on the type. Using appropriate representation invariants can make code easier to build, understand, and maintain. Our running example is the implementation of dictionaries using binary search trees.