2.7 Importance and Uses of Packages

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

Packages give us the most important ways of providing abstraction and encapsulation. They allow us to create a group of declarations, and to control the visibility of the declared items to client units. We say that a package exports resources to other, client units by declaring them in the visible part of its declaration.

According to [Barnes96] packages are "... what Ada is all about" and "The use of packages and private data types to hide unnecessary detail is the cornerstone of good Ada programming."

According to [Feldman96], "... the package ... is the essential programming tool to be used for going beyond the programming of very simple class exercises to what is generally called software engineering, or building real programs of real size for the real world. It is the package that allows us to develop a set of related operations and other entities, especially types, to test these thoroughly, and then to store them in an Ada program library for our future use or even to distribute them to others."

Packages may be used in many ways. The following four uses of a package were stressed in an early text on Ada 83. [Booch83]

The following taxonomy of package categories was provided by [Shumate89]

Many examples of packages that export other program units may be found in the predefined environment, including packages that provide input/output facilities. Upcoming example programs will illustrate all of the above and other uses of packages.

Related Topics

2.2 Program Units 2.6 Packages 2.9 Simple (ADO) Stack
2.10 Abstract (ADT) Stack 2.11 Generic Units 2.12 Nested Packages

[ Back to top of pagePrev ] Next ]