CS 228 meeting -*- Outline -*- * concepts (HR 3.1) ** introduction algorithms have data and control flow chapter 1 looked at control flow chapter 2 looked information hiding, modules that encapsulate data and functions support this now, and for rest of the book, focus on (ta dah) data abstraction ----------------------------- ABSTRACTION Ch. 1, control functions Ch. 2, information hiding modules (static) Ch. 3, data abstraction classes ----------------------------- data abstraction forms basis, organizing principle for data structures ** abstract data types (ADTs) ---------------------------- ABSTRACT DATA TYPES rational numbers abstract values: 1/2, 3/4, 2/3 operations: numr, denr, make-ratl polynomials abstract values: 3.0x^2 + 5.1x + 3.4 operations: degree, leading-coef, rest-of-poly input streams abstract values: operations: >>, .get, !, ... def: an *abstract data type* (ADT) is a type specified by: (1) a set of *abstract values*, and (2) specifications for the *operations* on the values ---------------------------- ----------------------------- WHY A MODULE IS NOT AN ADT An ADT allows clients to create many *instances* Table myTbl, myOtherTbl; A module hides data and functions, but: - there is only one in a program, - doesn't define a type of data. ----------------------------- e.g., password module. a type definition may be found in a module, but the module itself isn't an ADT