Ada 95 Quality and Style Guide Chapter 7

Chapter 7: Portability - TOC - 7.1 FUNDAMENTALS

7.1.5 Encapsulating Implementation Dependencies

guideline

  • Create packages specifically designed to isolate hardware and implementation dependencies and designed so that their specification will not change when porting.
  • Clearly indicate the objectives if machine or solution efficiency is the reason for hardware or implementation-dependent code.
  • For the packages that hide implementation dependencies, maintain different package bodies for different target environments.
  • Isolate interrupt receiving tasks into implementation-dependent packages.
  • Refer to Annex M of the Ada Reference Manual (1995) for a list of implementation-dependent features.

  • example

    See Guideline 7.1.3.

    rationale

    Encapsulating hardware and implementation dependencies in a package allows the remainder of the code to ignore them and, thus, to be fully portable. It also localizes the dependencies, making it clear exactly which parts of the code may need to change when porting the program.

    Some implementation-dependent features may be used to achieve particular performance or efficiency objectives. Commenting these objectives ensures that the programmer can find an appropriate way to achieve them when porting to a different implementation or explicitly recognize that they cannot be achieved.

    Interrupt entries are implementation-dependent features that may not be supported (e.g., VAX Ada uses pragmas to assign system traps to "normal" rendezvous). However, interrupt entries cannot be avoided in most embedded, real-time systems, and it is reasonable to assume that they are supported by an Ada implementation. The value for an interrupt is implementation-defined. Isolate it.

    notes

    You can use Ada to write machine-dependent programs that take advantage of an implementation in a manner consistent with the Ada model but that make particular choices where Ada allows implementation freedom. These machine dependencies should be treated in the same way as any other implementation-dependent features of the code.


    < Previous Page Search Contents Index Next Page >
    1 2 3 4 5 6 7 8 9 10 11
    TOC TOC TOC TOC TOC TOC TOC TOC TOC TOC TOC
    Appendix References Bibliography