COMP 3007 Lecture Notes - Lecture 7: Nth Metal, General Idea
Document Summary
Abstraction barriers: abstraction barriers isolate different levels of the system. -- (programs that use rational numbers) --- rational numbers in problem domain. --- (add-rational , subtract-rational , ) --- rational numbers as numerators and denominators. -- (make-rational, numerator, ) --- rational numbers as pairs. -- (cons, car, cdr) --- however pairs are implemented: barrier separates the program above that uses the data abstraction from the program below that implements the data abstraction, each level is the interface, for data abstraction: Identify basic set of operations: use only those operations, makes programs easier to maintain and modify later. For example: (define (numerator rational) (let ((g (gcd (car rational) (cdr rational)))) (/ (car rational) g))) What is meant by data: more than just selectors and constructors; more than just arbitrary set of procedures, must also specify conditions that these procedures must fulfill in order to be a valid representation, for example: