Introduction to OS APIs


Modular Structure of Software

The larger a computer program (measured in "lines of code") the more difficult it is for the programmer to keep the entire program in mind at once, and therefore the more difficult it is to avoid mistakes. There are two techniques for successfully writing large programs:

  1. Use a language that accomplishes more per "line of code."

    This has driven the evolution of programming languages from the original machine language to assembly language to "higher-level" programming languages (Admiral Grace Hopper's work inventing COBOL being among the first), and still later to so-called "third-generation" and "fourth-generation" programming environments.

  2. Program in functional modules, each of which is small enough for a person to grasp.

    • This works well if care is taken to limit the interactions between the functional modules, so that most of the code in each module can be considered in isolation.

    • This method also permits much more effective teamwork, because each individual programmer can work on one module, while other programmers work on other modules.

    • This approach emphasizes the value of analysis at the start of a programming project, breaking the tasks to be accomplished by the software into the appropriate modules.

    • For example, the operating system VMS contains over 64,000 modules with an aggregate total of over 50 million lines of source code, written in a dozen or more different languages.


Interaction Between Modules

There are several different ways in which a supposedly modular program can still be very difficult for a programmer to cope with:

Which modules invoke which other modules?

One way to visualize this is to create an overall dependency diagram with a block for each module and an arrow from each module to every other module that it invokes. If suitable placement of the blocks on the paper can result in none of these lines crossing each other, it will obviously be an easier program to keep straight in your mind than if the simplest possible arrangement resembles a spider web!

What are the possible sequences of execution of the various modules?

If there is only one possible sequence, so that module B is always invoked immediately after module A and immediately before module C, etc., it is much easier to grasp the program than if the sequence depends on user action, with some modules being executed repeatedly and others rarely or not even at all on some occasions when the program is used.

What are the methods by which information passes between modules?

Many programming languages provide specific mechanisms for passing information between modules, such a "arguments" or "parameters," "environment variables," "return values," "common blocks," and so on. Some programming languages require data variables to be shared among modules, some prevent it, and some permit it under programmer control.

The more different ways there are for information used by one module to be changed by the action of another module, the more difficult it is for the programmer to avoid mistakes.


Local and Global Scope of Variables


Arguments and Return Values


Operating System Services


Application Programming Interfaces


Undocumented Modules


Trusting vs. Careful Code Design


Notes

J. M. Fenster, 1998, "Amazing Grace." American Heritage of Invention & Technology, Fall, 1998, Volume 14, Number 2, pages 24-31.



Return to top

Return to MIS 300 Page


Dick Piccard revised this file (http://oak.cats.ohiou.edu/~piccard/mis300/osapis.htm) on September 11, 1998.

Please E-Mail comments or suggestions to "piccard@ohio.edu".


© Copyright 1998 Richard D. Piccard