Ada 95 Quality and Style Guide Chapter 8

Chapter 8: Reusability - TOC - 8.1 UNDERSTANDING AND CLARITY

8.1.2 Abbreviations

guideline

  • Do not use abbreviations in identifier or unit names.

  • example

    ------------------------------------------------------------------------
    with Ada.Calendar;
    package Greenwich_Mean_Time is
       function Clock return Ada.Calendar.Time;
       ...
    end Greenwich_Mean_Time;
    ------------------------------------------------------------------------
    

    The following abbreviation may not be clear when used in an application:

    with Ada.Calendar;
    with Greenwich_Mean_Time;
    ...
       function Get_GMT return Ada.Calendar.Time renames
              Greenwich_Mean_Time.Clock;
    

    rationale

    This is a stronger guideline than Guideline 3.1.4. However well commented, an abbreviation may cause confusion in some future reuse context. Even universally accepted abbreviations, such as GMT for Greenwich Mean Time, can cause problems and should be used only with great caution.

    The difference between this guideline and Guideline 3.1.4 involves issues of domain. When the domain is well-defined, abbreviations and acronyms that are accepted in that domain will clarify the meaning of the application. When that same code is removed from its domain-specific context, those abbreviations may become meaningless.

    In the example above, the package, Greenwich_Mean_Time, could be used in any application without loss of meaning. But the function Get_GMT could easily be confused with some other acronym in a different domain.

    notes

    See Guideline 5.7.2 concerning the proper use of the renames clause. If a particular application makes extensive use of the Greenwich_Mean_Time domain, it may be appropriate to rename the package GMT within that application:

    with Greenwich_Mean_Time;
    ...
       package GMT renames Greenwich_Mean_Time;
    


    < 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