40 likes | 139 Views
Abstract Data Types (ADTs). Chapter 15. Hiding Design Decisions. Why hide design decisions? The question perhaps should be: why expose them? By hiding the decisions on how data is manipulated and represented, we “reserve the right” to change the representation and means of manipulation!
E N D
Abstract Data Types (ADTs) Chapter 15
Hiding Design Decisions • Why hide design decisions? The question perhaps should be: why expose them? • By hiding the decisions on how data is manipulated and represented, we “reserve the right” to change the representation and means of manipulation! • This provides a degree of flexibility that insulates us from “tight binding” (close coupling) to the rest of the systems implementation.
ADT Signatures and Axioms • The “signature” is the graphical representation of the methods of access, and the operations that can occur. (see diagram 15.1, page 302). • ADT signatures are combined with other ADT signatures to show the interaction of the types within the system. • “Axioms” are the algebraic assertions about the ADTs that are useful for the programmer to know.
Encapsulation and C • C scoping rules and the preprocessor can be used to our advantage to encapsulate. • Manifest constants (in header files) can allow us to “conceal” (or pretend to) values that are actually used in the ADT implementation. • We can use the ‘extern’ directive to expose the actual manipulation routines. • We can use the ‘static’ declarations on functions to conceal internal details to routines outside of the compilation unit.