2.2 Program Units

[ Table of Contents ] Prev ] Chapter Overview ] Next ] [ Glossary/Index ]

The following table displays graphic symbols used here to represent various categories of Ada modules, called program units. The Ada Reference Manual [ARM95] and texts on Ada list six categories of program units: subprograms, packages, generic units, tasking units, protected units, and protected entries. We use four basic symbols (with variations), so the table is structured with four rows.

Program Unit Symbols


Im2-1a.gif (2274 bytes)

A subprogram is a module that performs actions by executing statements. There are two forms: the procedure and the function.

Im2-1b.gif (2250 bytes)

A package is a module that contains or "packages together" related resources. It has two separate parts: a declaration and body.

Im2-1c.gif (1723 bytes)

A task is a unit of concurrency. Each task has its own "thread of execution" and also has separate parts: declaration and body.

Im2-1d.gif (1968 bytes)

A protected unit provides coordinated access to shared data and also has separate parts: declaration and body.

In all of the symbols shown above the clear parts represent the unit declarations (which define interfaces to client units -- the "external" view) while the shaded parts represent the bodies (where implementation details are given -- the "internal" view). The small four-sided figures jutting out to the left in the symbols for the package, task and protected units represent the "visible part" of their declarations. (As we will see later, except in the case of subprograms there may be both visible and private parts to a declaration.)

The above symbols for subprogram, package and task are basically the same as symbols used by many Ada programmers for many years. They were made popular by Grady Booch in an early Ada text called "Software Engineering with Ada." [Booch83]

Generic units are templates, which form the basis for creating other units called generic instances via a process called generic instantiation. The dashed rectangles on top of the generic unit symbols represent the specification of formal generic parameters and actual generic parameters, respectively.

Tasks, task types, protected objects and protected types are discussed in a later chapter on concurrency and synchronization. In the remainder of this chapter and several subsequent chapters, all discussion and examples will be confined to "single thread" programs using only subprograms, packages and generic units.

The next page introduces several ways for "connecting" Ada program units, along with symbolic techniques for graphically representing such connections in architectural diagrams.

Related Topics

2.4 Procedures 2.5 Functions 2.6 Packages
6.1 Tasks 6.4 Protected Units

[ Back to top of pagePrev ] Next ]