Nov 10, 2003 ------------- - Introduction to data abstraction and OOP - Data abstraction typically involves - encapsulation (put everything in one place) - information-hiding (don't expose details needlessly) => often clubbed together as "abstract data types" - OOP typically adds to this mix - inheritance - dynamic method binding - Data abstraction: available in - Ada, Modula, C++, Java, EUCLID - Example ADT: Stack - defined by interface - Example Stack operations - push - pop - top - isempty - Can define Stack by some "Axioms" - pop(push(stack,element)) = stack - top(push(stack,element)) = element - isempty(create) = true - ... - Examples of ADT implementations - Ada - C++ - Java - Ada - called "packages" - specification - implementation - but packages can be anything thrown together - private, public, and limited private members - no constructors or destructors - C++ - called "structs" or "classes" - difference lies in default access patterns - public, private, protected - both stack and heap allocation possible - constructors and destructors can both be defined - Java - called "classes" - ditto - only constructor provided, no destructors (why?) - can also have "templates" - parameterized ADTs