Section 15.1 - Ada Program Structure

Because this is a tutorial I've used very short programs and program fragments to demonstrate specific points. Real Ada programs are developed instead as a set of (many) Ada packages. Each package has a declaration that publicly declares the facilities it makes available, and each package has a body to implement that public declaration.

Packages are the principle structuring facility in Ada. Packages are intended to be used to directly support abstraction, information hiding, and modularization. For example, packages are useful for encapsulating machine dependencies.

It isn't easy to describe program structuring issues, because that's really a program design question, not just a language question. Some recommendations are given in Ada Quality and Style: Guidelines for Professional Programmers, particularly in Chapter 4 ("Program Structure"). Here are some of those guidelines:

Note that Ada is different from some other languages. Ada separates the concept of type from the concept of module (package); some other languages merge the two concepts (particularly Eiffel, and to a lessor degree C++). Each approach has its advantages and disadvantages, which we won't delve into here.


Quiz:

Which of the following statements is false?

  1. Hide the implementation details from the users - Put only what is needed for the use of a package into its specification.
  2. You should avoid creating packages that are simply collections of unrelated objects and subprograms.
  3. Packages are rarely used in real Ada programs.
  1. Statement 1.
  2. Statement 2.
  3. Statement 3.

You may also:

PREVIOUS Go back to the previous section

NEXT     Skip to the next section

OUTLINE  Go up to lesson 15 outline

David A. Wheeler (dwheeler@dwheeler.com)

The master copy of this file is at "http://www.adahome.com/Tutorials/Lovelace/s15s1.htm".