Procedural Abstraction and Recursion
Programming and Introductory Data Structures
Abstraction is a many-to-one mapping that reduces complexity
and eliminates unnecessary details by providing only those details
For example, there are several ways to implement a multiplication
algorithm (table lookup, summing, etc.
Each looks quite
different internally than the other, but they do the same thing.
general, a user won’t care how it’s done, just that it multiplies.
There are two types of abstraction:
Procedural (the topic of the next three weeks)
Decomposing a program into
is a way of
providing “computational” abstractions.
Rather than simply being collections of commonly used code,
functions provide a useful tool for implementing procedural
abstraction within a program.
For any function, there is a person who
function (the author) and a person who
the function (the
The author needs to think carefully about
the function is
supposed to do, as well as
the function is going to do it.
In contrast, the client only needs to consider the
, not the
is much more complicated, this is a Big Win
for the client!
In individual programming, you will often be the author and
Sometimes it is to your advantage to “forget the
details” and only concentrate on higher levels of functionality.
Procedural abstractions, done properly, have two important
the implementation of an abstraction can be understood
without examining any other abstraction implementation.
you can replace one (correct) implementation of an
abstraction with another (correct) one, and no callers of that
abstraction will need to be modified.
These properties only apply to
abstractions, not the abstractions themselves.
It is CRITICALLY IMPORTANT to get the
before you start writing a bunch of code.
If you change the
that is offered, the change is not
local, nor is the new version substitutable.
Unfortunately, abstraction limits the scope of change.
If you need to change what a procedural abstraction does, it
can involve many different changes in the program.
However, if a change can be limited to replacing the
implementation of an abstraction with a substitutable
implementation, then you are guaranteed that no other part
of the project needs to change.
This is vital for projects
that involve many programmers.