Procedural abstraction

Procedural abstraction is when we write code sections (called "procedures" or in Java, "static methods") which are generalised by having variable parameters. The idea is that we have code which can cope with a variety of different situations, depending on how its parameters are set when it is called. It makes a program shorter and easier to understand, and helps debugging, since when we correct a procedure, we correct the program for all the cases where the procedure is called.

A "bottom-up" approach to introducing procedural abstraction is to look at cases where we have code which is similar to other pieces, or pieces which follow a common pattern, and see if there is a way we can convert these to calls to one procedure. A "top-down" approach is to think of the generalised operation we want to do, write code which uses calls to the procedure for this operation, and then write code for the procedure.

The top-down approach leads to the idea of writing code to specifications. We say precisely what we want a procedure to do in terms of its arguments, and expect it to do just that, nothing more and nothing less. Then we need have no knowledge of what is inside the procedure to make successful use of it. When we write the procedure, we need have no knowledge of the code which is going to make use of the procedure. This helps us break programs down into small manageable parts, perhaps handled by different programmers. Then if we know the only way different pieces of a program can interact is through procedure calls which have a carefully defined effect, it is easier for us to debug and modify program with less chance that changing one part will have an unexpected effect on another part.

Procedural abstraction is all about generalising doing some action. A procedure is called, performs the action, and is then finished. The procedure may return some value, or it may change the state of some of its arguments, or it may cause some external event to happen (input/output of some sort), or it may cause some combination of these.

Procedural abstraction is covered in Chapter 3 of the Liskov book. Other good reading on the subject is given in the links below: