4.7 Summary.
We have covered probably more new ground in this chapter than in everything else so far. To recap we now know how to write packages, how to use packages, that you can nest packages, how to implement hierarchical package libraries, what the visibility rules on packages are, how to use packages to develop abstract data types and some tips and tricks for successful package development.
Where does all this get us, well we have said already that we can now restructure our example into a sensible package hierarchy, which will look something like this (so far):
Ada_Store Log PoST Application Device CashDrawer Display Keyboard OS_Interface (private) Printer Scanner Input_Queue Station Support List Trace Trading Department Item Tender Transaction User
This hierarchy has one single root, which contains three complete packages (Log, Station and User) and three subsystems, PoST, Support and Trading. The specification for the root package follows, it declares the standard types used throughout the system, note also that it is declared as a Pure package and that it does not require a body or any substantial elaboration.
To review we will include the specification for Ada_Store.Support.Trace (seen above) and another important package Ada_Store.PoST.Input_Queue which is used to manage an ordered queue of input from the peripheral devices.
This chapter has brought to you one of the most important language features of Ada, the package it is essential to understand packages before you can develop and code beyond single procedure applications like hello-world.
The following two chapters build upon packages extensively so I suggest a break at this point, have a coffee, review the examples (in the text and on the CD) and even try writing some of your own (using a GNAT compiler from the CD if there is one for your computer).
Copyright ©
1996 Simon Johnston &
Addison Wesley Longman