Naming ADT Files

There are three kinds of files associated with the implementation of an abstract data type:

In the case of the int_stack example, the three files will be called int_stack.h, int_stack-private.h and int_stack.c.

What we are doing is, by convention, setting up the following contract between the (writer of the) ADT and the rest of the program(mers): as long as the rest of the program agrees to manipulate the ADT solely by using the functions in the public header, the ADT will guarantee that its behavior will not change.

This means, in particular, that the ADT writer is allowed to change the implementation of the ADT in any manner they feel, as long as the behavior of the public functions does not change.

Note that it is perfectly acceptable for the public header to #include the private header.

It may be necessary for some piece of code to use a function that is not guaranteed. Such a function will need to be in the private header, and every time there is a change, special action will have to be taken.

Next Prev Main Top Feedback