home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / educ / titr.doc < prev    next >
Encoding:
Text File  |  1988-05-03  |  69.4 KB  |  1,533 lines

  1.  
  2.  
  3.  
  4.                                            |||||||||||||||||||||||||
  5.                                            |||||||||||||||||||||||||
  6.                                            |||||||||||||||||||||||||
  7.                                            |||||||||||||||||||||||||
  8.                                            |||||||||||||||||||||||||
  9.  
  10.                                               Technical Report on
  11.                                                Tools Designed by
  12.                                                Texas Instruments
  13.                                            =========================
  14.                                                 Forms Generator
  15.                                                 Spelling Checker
  16.                                                 Style Checker
  17.                                                 Virtual Terminal
  18.  
  19.         Prepared for:                      |||||||||||||||||||||||||
  20.                                            |||||||||||||||||||||||||
  21.         NAVAL OCEAN SYSTEMS CENTER (NOSC)  |||||||||||||||||||||||||
  22.         United States Navy                 |||||||||||||||||||||||||
  23.         San Diego, Ca   92152              |||||||||||||||||||||||||
  24.                                            |||||||||||||||||||||||||
  25.         Contract No. N66001-84-R-0030      |||||||||||||||||||||||||
  26.                                            |||||||||||||||||||||||||
  27.                                            |||||||||||||||||||||||||
  28.                                            |||||||||||||||||||||||||
  29.                                            |||||||||||||||||||||||||
  30.                                            |||||||||||||||||||||||||
  31.                                            |||||||||||||||||||||||||
  32.                                            |||||||||||||||||||||||||
  33.                                            |||||||||||||||||||||||||
  34.                                            |||||||||||||||||||||||||
  35.                                            |||||||||||||||||||||||||
  36.                                            |||||||||||||||||||||||||
  37.                                            |||||||||||||||||||||||||
  38.                                            |||||||||||||||||||||||||
  39.                                            |||||||||||||||||||||||||
  40.                                            |||||||||||||||||||||||||
  41.                                            |||||||||||||||||||||||||
  42.           Equipment Group - ACSL           |||||||||||||||||||||||||
  43.           P.O. Box 801, M.S. 8007          |||||||||||||||||||||||||
  44.           McKinney, Texas  75069           |||||||||||||||||||||||||
  45.           15 April 1985                    |||||||||||||||||||||||||
  46.                                            |||||||||||||||||||||||||
  47.  
  48.                                                TEXAS INSTRUMENTS
  49.                                                   INCORPORATED
  50.  
  51.                                            |||||||||||||||||||||||||
  52.                                            |||||||||||||||||||||||||
  53.                                            |||||||||||||||||||||||||
  54.                                            |||||||||||||||||||||||||
  55.                                            |||||||||||||||||||||||||
  56.  
  57.  
  58.  
  59.                                    CONTENTS
  60.  
  61.  
  62.  
  63. CHAPTER 1       INTRODUCTION
  64.  
  65.  
  66. CHAPTER 2       ADA LANGUAGE DESIGN ISSUES
  67.  
  68.                 INTRODUCTION . . . . . . . . . . . . . . . . . . . 2-1
  69.                 VISIBILITY . . . . . . . . . . . . . . . . . . . . 2-1
  70.                   With/Use Statement . . . . . . . . . . . . . . . 2-1
  71.                   Renames/Subtype Usage  . . . . . . . . . . . . . 2-2
  72.                 SUBTYPES OF ENUMERATION TYPES  . . . . . . . . . . 2-3
  73.                 "MONGOLIAN HORDES" . . . . . . . . . . . . . . . . 2-4
  74.                 OVERLOADING  . . . . . . . . . . . . . . . . . . . 2-5
  75.                 USES OF "SEPARATE" . . . . . . . . . . . . . . . . 2-7
  76.                   Example Of Ideal Use Of Separates  . . . . . . . 2-7
  77.                   Adding Separate Elements To The System . . . . . 2-7
  78.                   Dangers Of Separates . . . . . . . . . . . . . . 2-7
  79.                   Separate Supporting Different Implementations Of 
  80.                   A Body . . . . . . . . . . . . . . . . . . . . . 2-8
  81.                 OBJECT-ORIENTED DESIGN AND OFFLOADING  . . . . . . 2-8
  82.  
  83.  
  84. CHAPTER 3       SOFTWARE PRODUCTIVITY INFORMATION
  85.  
  86.                 REUSABILITY OF SOFTWARE  . . . . . . . . . . . . . 3-1
  87.                 SOFTWARE LIFE CYCLE LABOR DISTRIBUTION . . . . . . 3-3
  88.                 PRODUCTIVITY (LOC) . . . . . . . . . . . . . . . . 3-4
  89.  
  90.  
  91. CHAPTER 4       IMPLEMENTING IN THE ADA DEVELOPMENT ENVIRONMENT (ADE)
  92.  
  93.                 INTRODUCTION . . . . . . . . . . . . . . . . . . . 4-1
  94.                 PERFORMANCE CONSIDERATIONS . . . . . . . . . . . . 4-1
  95.                 THE DEBUGGER . . . . . . . . . . . . . . . . . . . 4-3
  96.                 WORKAROUNDS  . . . . . . . . . . . . . . . . . . . 4-4
  97.                 UNCHECKED DEALLOCATION . . . . . . . . . . . . . . 4-5
  98.                 THE PREDEFINED PACKAGE "CURRENT_EXCEPTION" . . . . 4-5
  99.  
  100.  
  101. CHAPTER 5       TRANSPORTABILITY ISSUES
  102.  
  103.                 INTRODUCTION . . . . . . . . . . . . . . . . . . . 5-1
  104.                 SYSTEM DEPENDENCIES  . . . . . . . . . . . . . . . 5-1
  105.                 DATA GENERAL VS DIGITAL EQUIPMENT  . . . . . . . . 5-1
  106.                   Physical Transportation Problems . . . . . . . . 5-2
  107.                   Towers Of Hanoi  . . . . . . . . . . . . . . . . 5-2
  108.  
  109.  
  110. CHAPTER 6       TOOL EXTENSION TOPICS
  111.  
  112.                 INTERACTIVE FORM/BATCH GENERATOR . . . . . . . . . 6-1
  113.                   Automated Form Generation  . . . . . . . . . . . 6-1
  114.                                                                 Page 2
  115.  
  116.  
  117.                   Key Mapping Interface  . . . . . . . . . . . . . 6-1
  118.                   More Display Renditions  . . . . . . . . . . . . 6-1
  119.                   More Field Types . . . . . . . . . . . . . . . . 6-1
  120.                 STYLE CHECKER  . . . . . . . . . . . . . . . . . . 6-2
  121.                 SPELLING CHECKER . . . . . . . . . . . . . . . . . 6-3
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.                               CHAPTER 1
  135.  
  136.                              INTRODUCTION
  137.  
  138.  
  139.  
  140.            Texas Instruments is pleased to submit this  final  technical
  141.       report  for  contract  N66001-84-R-0030, Ada(tm) tools for the WIS
  142.       program.  Under this contract, Texas  Instruments  Ada  Technology
  143.       Branch has developed the following tools:
  144.  
  145.        -  Ada Style Checker
  146.  
  147.        -  Virtual Terminal
  148.  
  149.        -  Batch/Interactive Forms Generator System
  150.  
  151.        -  Spelling Corrector
  152.  
  153.  
  154.            This report will cover several topics:
  155.  
  156.        -  Experiences in using various features of the Ada language.
  157.  
  158.        -  Specific circumstances in implementing these tools on the Data
  159.           General Ada Development Environment (ADE).
  160.  
  161.        -  Transportability issues, which  will  be  addressed  from  the
  162.           consolidated viewpoint of all the above tools.
  163.  
  164.        -  Possible   tool   extensions,   addressed   for   each    tool
  165.           individually.
  166.  
  167.        -  The software development process  used  on  this  contract  in
  168.           terms  of  productivity  (lines  of  code),  activities in the
  169.           software life cycle, and examples of  software  reuse.   Texas
  170.           Instruments  established  a  data  gathering  program  at  the
  171.           beginning of this effort in order  to  make  such  evaluations
  172.           possible.
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.                                CHAPTER 2
  187.  
  188.                        ADA LANGUAGE DESIGN ISSUES
  189.  
  190.  
  191.  
  192.       2.1  INTRODUCTION
  193.  
  194.            This chapter addresses issues pertaining  to  the  design  of
  195.       software written in Ada.  These issues include:
  196.  
  197.        -  the application of visibility
  198.  
  199.        -  problems in using subtypes of enumeration types
  200.  
  201.        -  effective application of personnel en masse
  202.  
  203.        -  overloading
  204.  
  205.        -  application of separate compilation
  206.  
  207.        -  object-oriented design and offloading of the design and coding
  208.           efforts
  209.  
  210.  
  211.       2.2  VISIBILITY
  212.  
  213.       2.2.1  With/Use Statement
  214.  
  215.            The Texas Instruments' Ada  Programming  Standards  recommend
  216.       the  use  of  the  WITH statement without the USE statement.  This
  217.       guideline is recommended  for  understandability  and  clarity  of
  218.       locations  of  program  units.   Following this guideline produces
  219.       very long names which helps the understandability of  the  program
  220.       unit.   However,  one undesirable side effect of this guideline is
  221.       that infix operators are no longer  valid  for  types  defined  in
  222.       other  packages.   Using  the  function  call syntax for operators
  223.       rather than the infix operator syntax really  distracts  from  the
  224.       readability of the expression, as shown in the following example:
  225. ADA LANGUAGE DESIGN ISSUES                                    Page 2-2
  226.  
  227.  
  228.  
  229.  
  230.         package ENUM_PACKAGE;
  231.  
  232.             type ENUM is (VALUE_1, VALUE_2);
  233.  
  234.         end;
  235.  
  236.       -- without USE
  237.  
  238.         procedure EXAMPLE(E : in ENUM_PACKAGE.ENUM) is
  239.  
  240.         begin
  241.  
  242.             if ENUM_PACKAGE."="(E, ENUM_PACKAGE.VALUE_1) then
  243.                 null;
  244.             end if;
  245.  
  246.         end EXAMPLE;
  247.  
  248.       -- with USE
  249.  
  250.         with ENUM_PACKAGE; use ENUM_PACKAGE;
  251.         procedure EXAMPLE(E : in ENUM) is
  252.  
  253.         begin
  254.  
  255.             if E = VALUE_1 then
  256.                 null;
  257.             end if;
  258.  
  259.         end EXAMPLE;
  260.  
  261.       2.2.2  Renames/Subtype Usage
  262.  
  263.            In defining a system of packages,  it  may  be  desirable  to
  264.       define  a  set  of global types and constants in a package.  Other
  265.       packages can then be defined  which  define  operations  involving
  266.       objects  of these global types.  Finally an application routine or
  267.       package wants to use the operations defined  in  the  intermediate
  268.       packages.   In  this  case the application routine or package must
  269.       either WITH  the  global  package  which  defines  the  types  and
  270.       constants,  or  the  intermediate  package  must  pass  the global
  271.       information through.  The WITH of the global package  may  not  be
  272.       desirable  because  we  want  to  hide the existence of the global
  273.       package  to  the  application  routine  or  packages.   Types  are
  274.       normally  renamed  by using the SUBTYPE statement.  Even though an
  275.       enumeration type is renamed using this mechanism, the value  names
  276.       are  not made visible.  These values must be made visible by using
  277.       the CONSTANT statement which defines a new  local  name  for  each
  278.       constant.  The following is a simple example of this problem.
  279. ADA LANGUAGE DESIGN ISSUES                                    Page 2-3
  280.  
  281.  
  282.  
  283.  
  284.  
  285.         procedure SUBTYPE_EXAMPLE is
  286.  
  287.             package PACKAGE_ONE is
  288.  
  289.                 type TYPE_ONE is (VALUE_1, VALUE_2);
  290.  
  291.             end PACKAGE_ONE;
  292.  
  293.             package PACKAGE_TWO is
  294.  
  295.                 subtype TYPE_TWO is PACKAGE_ONE.TYPE_ONE;
  296.  
  297.                 VALUE_ONE: constant TYPE_TWO := PACKAGE_ONE.VALUE_1;
  298.                 VALUE_TWO: constant TYPE_TWO := PACKAGE_ONE.VALUE_2;
  299.  
  300.             end PACKAGE_TWO;
  301.  
  302.             VALUE: PACKAGE_TWO.TYPE_TWO;
  303.  
  304.         begin
  305.  
  306.             VALUE := PACKAGE_ONE.VALUE_1;
  307.             VALUE := PACKAGE_TWO.VALUE_TWO;
  308.  
  309.         end SUBTYPE_EXAMPLE;
  310.  
  311.       2.3  SUBTYPES OF ENUMERATION TYPES
  312.  
  313.            A method that has become increasingly popular is the  use  of
  314.       subtypes  to  "rename"  a  type from another package.  One must be
  315.       cautious when attempting to use subtypes  for  this  purpose.   In
  316.       particular,  one  should  be  aware  that  the  specification of a
  317.       subtype of an enumeration  type  does  not  make  the  enumeration
  318.       literals  visible.   The  enumeration  literals must be explicitly
  319.       renamed as in the following example.
  320.  
  321.          package HIDDEN_PACKAGE is
  322.            type ENUMERATION is (ONE, TWO, THREE);
  323.          end HIDDEN_PACKAGE;
  324.  
  325.          with HIDDEN_PACKAGE;
  326.          package VISIBLE_PACKAGE is
  327.            subtype ENUMERATION is HIDDEN_PACKAGE.ENUMERATION;
  328.  
  329.            function ONE   return ENUMERATION renames HIDDEN_PACKAGE.ONE;
  330.            function TWO   return ENUMERATION renames HIDDEN_PACKAGE.TWO;
  331.            function THREE return ENUMERATION renames HIDDEN_PACKAGE.THREE;
  332.          end VISIBLE_PACKAGE;
  333.  
  334.            The problem with this mechanism is that it not only hides the
  335.       enumeration  literals,  but it also hides the ordering information
  336.       associated  with   the   enumeration   literal.    The   user   of
  337. ADA LANGUAGE DESIGN ISSUES                                    Page 2-4
  338.  
  339.  
  340.       VISIBLE_PACKAGE  doesn't  know  whether  all  of  the  literals of
  341.       subtype ENUMERATION are visible or not.  Thus, objects of  subtype
  342.       ENUMERATION  may  have values that the package user cannot express
  343.       as a literal.
  344.  
  345.       2.4  "MONGOLIAN HORDES"
  346.  
  347.            TI was able to  successfully  apply  the  "Mongolian  hordes"
  348.       programming approach to the coding of some of the software for the
  349.       spelling checker tool.  Success in this case is  measured  by  the
  350.       fact  that  the tool works and was delivered on-time.  This showed
  351.       that adding more programmers to a given task in order to  get  the
  352.       task   done  faster  can  succeed,  but  with  restrictions.   The
  353.       restrictions:
  354.  
  355.        *  The design needed to be complete before the programmers  could
  356.           be   brought   in.    All  of  the  interfaces  needed  to  be
  357.           well-defined between the various packages.  Such was  not  the
  358.           case  originally,  and  time was expended in resolving several
  359.           design issues after coding began.
  360.  
  361.        *  Object-oriented design techniques were applied.  This  divided
  362.           the  programming effort into a group of packages, each package
  363.           coded by one programmer and each  package  providing  all  the
  364.           operations  on  and  access  to a particular object (such as a
  365.           document    or    spelling    dictionary).      Also,     each
  366.           object-controlling package can be unit-tested extensively by a
  367.           "testing" person.  Two people  work  on  each  object-oriented
  368.           package:  one codes and another tests.
  369.  
  370.        *  Any problems with the interface specifications were ironed out
  371.           in  design  reviews,  progress reviews, and code walkthroughs.
  372.           All individuals involved with coding and testing were  present
  373.           at  the  reviews,  and  a  package  of  common  constants  and
  374.           interface parameters was developed and made available  to  all
  375.           coders  at  this  time.   Package  interface  definitions were
  376.           rigidly enforced, and any changes  to  these  interfaces  were
  377.           carefully considered and discussed during these reviews.
  378.  
  379.  
  380.            The spelling corrector was the only tool this  technique  was
  381.       applied  to.   Unlike  the  other three tools worked on by TI, the
  382.       spelling corrector encountered problems  with  personnel  turnover
  383.       (including  the  loss  of  one designer/programmer and a change in
  384.       leadership on the tool) and a gap in schedule in which no work was
  385.       done.    The   spelling  corrector  project  had  many  more  code
  386.       walkthroughs  than  the  other  three  projects.   Note  that  its
  387.       productivity  figures (see Chapter 3 of this report) significantly
  388.       differ from the other three tools.  Some key differences are:
  389. ADA LANGUAGE DESIGN ISSUES                                    Page 2-5
  390.  
  391.  
  392.  
  393.       Metric              Spelling Corrector  Other Tools (Average)
  394.       ==================  ==================  =====================
  395.       Lines of Source
  396.          Code (semicolons)
  397.          per Day               14.5                 17.4
  398.  
  399.       Lines of Source
  400.          Code (semicolons)
  401.          per Manmonth         311.0                374.2
  402.  
  403.       Comment Lines          2626                 1437  (590 to 2013)
  404.  
  405.  
  406.            Conclusions:
  407.  
  408.        *  Productivity was lower for the "Mongolian hordes" application,
  409.           but  it was still relatively high (versus some "rule of thumb"
  410.           figures of 7 or 8 LOC/day).
  411.  
  412.        *  Inline documentation was greater for  the  "Mongolian  hordes"
  413.           application.   Perhaps this was caused by the greater need for
  414.           each coder and tester to communicate with each  other  and  to
  415.           document the interfaces as precisely as possible.
  416.  
  417.        *  The  application  of  "Mongolian  hordes"  can  work  if   the
  418.           circumstances are right.
  419.  
  420.        *  A contractor does not want to find himself in the position  of
  421.           having to apply this technique on a project.  If the situation
  422.           arises, Ada provides a good mechanism to help achieve success.
  423.  
  424.  
  425.       2.5  OVERLOADING
  426.  
  427.            One of the often criticized  features  of  Ada  is  that  the
  428.       output facilities are very rigid and the predefined I/O facilities
  429.       are limited.  Experience producing an output report has  shown  us
  430.       that this need not be so.  Overloading subprograms and good use of
  431.       default parameters can create I/O which is much easier to use than
  432.       the predefined TEXT_IO functions.
  433.  
  434.            In the process of producing the Style Checker output,  a  set
  435.       of  output  routines  supporting various formats were created (see
  436.       the following code for examples).  These were all given  the  same
  437.       overloaded  name.   Whenever  possible,  the  parameters  of these
  438.       subprograms were  given  default  values.   These  allowed  us  to
  439.       produce  general  output  lines  in  a  variety of formats without
  440.       having to do multiple detailed TEXT_IO.PUTs to generate each line.
  441. ADA LANGUAGE DESIGN ISSUES                                    Page 2-6
  442.  
  443.  
  444.           procedure PUT_REPORT_LINE(INDENTION         : in NATURAL;
  445.                                     HEADER            : in STRING;
  446.                                     ASTERIK_NEEDED    : in BOOLEAN := FALSE;
  447.                                     EXCLAMATION_NEEDED: in BOOLEAN := FALSE) is
  448.  
  449.  
  450.           procedure PUT_REPORT_LINE(INDENTION         : in NATURAL;
  451.                                     STYLE_ISSUE       : in STRING;
  452.                                     SUB_HEADING       : in STRING;
  453.                                     LEAD_IN           : in CHARACTER;
  454.                                     COUNT             : in NATURAL;
  455.                                     UNITS             : in STRING;
  456.                                     ASTERIK_NEEDED    : in BOOLEAN := FALSE;
  457.                                     EXCLAMATION_NEEDED: in BOOLEAN := FALSE) is
  458.  
  459.  
  460.           procedure PUT_REPORT_LINE(INDENTION         : in NATURAL;
  461.                                     STYLE_ISSUE       : in STRING;
  462.                                     SUB_HEADING       : in STRING;
  463.                                     LEAD_IN           : in CHARACTER;
  464.                                     COUNT             : in FLOAT;
  465.                                     UNITS             : in STRING;
  466.                                     ASTERIK_NEEDED    : in BOOLEAN := FALSE;
  467.                                     EXCLAMATION_NEEDED: in BOOLEAN := FALSE) is
  468.  
  469.           procedure PUT_REPORT_LINE(INDENTION         : in NATURAL;
  470.                                     STYLE_ISSUE       : in STRING;
  471.                                     SUB_HEADING       : in STRING;
  472.                                     LOWER_BOUND       : in NATURAL;
  473.                                     UPPER_BOUND       : in NATURAL;
  474.                                     UNITS             : in STRING;
  475.                                     ASTERIK_NEEDED    : in BOOLEAN := FALSE;
  476.                                     EXCLAMATION_NEEDED: in BOOLEAN := FALSE) is
  477.  
  478.           procedure PUT_REPORT_LINE(
  479.                       KEYWORD_REPORT  : in STYLE_PARAMETERS.KEYWORD_USE_DESCRIPT;
  480.                       KEYWORD_COUNT   : in NATURAL;
  481.                       KEYWORD_USAGE   : in FLOAT;
  482.                       KEYWORD_TYPE    : in TOKENIZER.TOKEN_TYPE) is
  483.  
  484.  
  485.  
  486.  
  487.            This allows easy output without  the  user  having  to  worry
  488.       about detailed formatting problems.
  489.  
  490.            If used indiscriminately,  overloading  can  make  a  program
  491.       unreadable  by allowing different operations to be called with the
  492.       same name.  In our case, all the  functions  were  performing  the
  493.       same  operation,  merely  with  different types on inputs and with
  494.       slightly different formats.
  495.  
  496.            Overloading can be useful  if  functions  are  being  created
  497.       which perform the same operation with only minor variations, where
  498.       these variations are not likely to become confused.
  499. ADA LANGUAGE DESIGN ISSUES                                    Page 2-7
  500.  
  501.  
  502.       2.6  USES OF "SEPARATE"
  503.  
  504.            The "separate" capability allows a  subunit  to  be  compiled
  505.       independently  from  the  parent unit.  The separate feature eases
  506.       program development once the user realizes that the separate  unit
  507.       must be compiled AFTER the parent unit is compiled.
  508.  
  509.            Poorly used separates (used in a poorly planned  development)
  510.       can  cause  the  process  of  compilation  to become confusing and
  511.       difficult.  Well used separates can make the process of  modifying
  512.       a system simple.
  513.  
  514.       2.6.1  Example Of Ideal Use Of Separates
  515.  
  516.            The ideal use  for  separates  is  to  enable  easy  top-down
  517.       development  of  a well-designed system.  A candidate system would
  518.       be a large unit which contains many smaller subunits.  In a  small
  519.       system,  or  one  where  most  of  the system consists of "withed"
  520.       packages, it is not as important to break out pieces for  separate
  521.       compilation.
  522.  
  523.            The  top  level  of  this  system  should  be   well-defined,
  524.       especially the interfaces.  To start development, the top level is
  525.       composed, including "is separate" references to ALL the  subunits.
  526.       A null stub for each of the separate subunits is created.
  527.  
  528.            Now  the  system  can  be  compiled.    There   may   be   no
  529.       functionality   to   the  system,  but  it  can  be  incrementally
  530.       developed.
  531.  
  532.       2.6.2  Adding Separate Elements To The System
  533.  
  534.            When the user is ready, any of the separate subunits  can  be
  535.       developed.   To  add  this  to  the system it is only necessary to
  536.       compile the subunit and  re-link  the  system.   If  the  separate
  537.       decomposition has been done properly, the addition of subunits can
  538.       be done easily.
  539.  
  540.            Note that the entire system did not  have  to  be  recompiled
  541.       when  another  subunit  was  added.   This  is  the  advantage  of
  542.       separates in that adding to the system only requires compiling the
  543.       new subunit and linking!
  544.  
  545.       2.6.3  Dangers Of Separates
  546.  
  547.            The goal of separates is to  allow  changes  without  massive
  548.       recompilation.   If  the  parent  unit  is  not well specified and
  549.       frequent changes are necessary to that unit, even more compilation
  550.       will  be  necessary.  Each time the parent unit is changed, all of
  551.       the separate subunits have to be compiled again.
  552.  
  553.            The parent unit must be well-defined for separate compilation
  554.       to be productive.
  555. ADA LANGUAGE DESIGN ISSUES                                    Page 2-8
  556.  
  557.  
  558.       2.6.4  Separate Supporting Different Implementations Of A Body
  559.  
  560.            Another possible use of separate would be to allow  a  change
  561.       in  an  implementation merely by relinking.  This would be done by
  562.       having a fixed specification to a unit and have different separate
  563.       bodies  in  different  libraries.  Then the implementation methods
  564.       would depend on which of  the  libraries  was  used  to  link  the
  565.       system.
  566.  
  567.            An example of this might  be  to  have  bodies  of  two  sort
  568.       procedures  using  different  methods  available.   The user could
  569.       choose which type of sort to use by  selecting  the  library  from
  570.       which to link.
  571.  
  572.            Unfortunately this was not available for our  use  since  the
  573.       Data  General  Ada Development Environment does not support bodies
  574.       which exist in different libraries than their specifications.
  575.  
  576.       2.7  OBJECT-ORIENTED DESIGN AND OFFLOADING
  577.  
  578.            Offloading is the delegation of  segments  of  a  project  to
  579.       separate  computers, such as personal computers.  This reduces the
  580.       load on main computers and may increase productivity by increasing
  581.       the  responsiveness  of the computer to the user and providing the
  582.       user with a dedicated resource.  With the  reduction  in  hardware
  583.       costs  and  the  increase  in personnel costs, offloading may be a
  584.       cost-effective approach to software development.
  585.  
  586.            For very large projects, especially when a good CM system  or
  587.       library  management  system is NOT available to keep the libraries
  588.       in sync, offloading may not be feasible.  However, there are  many
  589.       situations  in  which  offloading (at least during unit coding and
  590.       testing) is quite feasible.
  591.  
  592.            In the Spelling Checker program,  a  small-  to  medium-sized
  593.       effort,  the  design  was  oriented around two major objects:  the
  594.       DOCUMENT to be checked and the DICTIONARY (there can be more  than
  595.       one)  to  check  against.   There are two packages which deal with
  596.       these objects, DOCUMENT_HANDLER and DICTIONARY_MANAGER,  and  each
  597.       package  was  assigned  to  one person to code and unit test.  The
  598.       specifications, which, of course, were  subject  to  change,  were
  599.       planned  during  the  design phase, and the development (including
  600.       coding and unit testing)  of  the  bodies  was  done  in  complete
  601.       independence.   Such  development could easily have been offloaded
  602.       to a PC if an Ada compiler existed for one.  The only  requirement
  603.       for  this  would  be  that  the  MACHINE_DEPENDENCIES  packages be
  604.       duplicated on each PC.  Each package was in  complete  control  of
  605.       its  object;  the  DOCUMENT_HANDLER  was  given the name of a file
  606.       containing a document and provided words and  context  information
  607.       to  its  user.   The DOCUMENT_HANDLER is the object manipulator of
  608.       objects known as documents (which realize physical implementations
  609.       as  files).  The user was never concerned with details of document
  610.       structure or manipulation.
  611. ADA LANGUAGE DESIGN ISSUES                                    Page 2-9
  612.  
  613.  
  614.            The object-oriented design approach is useful:
  615.  
  616.        *  It localizes problem areas.   When  a  bug  is  reported,  the
  617.           source  of  the  bug  can  be quickly isolated to a particular
  618.           object manipulator.
  619.  
  620.        *  It supports complete unit  testing.   If  the  interfaces  are
  621.           well-known  and  each  unit  is  thoroughly  tested, the later
  622.           integration can go  quite  smoothly.   TI  has  had  noticable
  623.           success  in  this  area  in  its  design  of  the  NOSC tools,
  624.           particularly the spelling checker which was designed  by  five
  625.           people over the course of the project and integrated in half a
  626.           day.
  627.  
  628.        *  It provides a clean break for  division  of  the  work.   Each
  629.           object manipulator is independent of the other routines in the
  630.           system and its interface is well-defined.  Hence,  one  person
  631.           could design and code it without interfacing with others until
  632.           integration time.
  633.  
  634.  
  635.            The second point supports offloading.  The object manipulator
  636.       can be designed on a personal computer and tested with a validated
  637.       Ada compiler on that PC.  Test programs can  be  written  locally,
  638.       and  the  object manipulator can be unit tested extensively.  Once
  639.       complete, it can be uploaded to the host computer for  integration
  640.       into the system and system testing.
  641.  
  642.            The  cost  savings  of  this  development  technique  can  be
  643.       substantial.   Many  Ada  compilations  can  be  performed  on the
  644.       personal computer at a less cost than those performed on the  host
  645.       machine.   Also, the productivity of the designer and coder can be
  646.       greater due to the increased availability and  dedication  of  the
  647.       personal computer resource.
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.                                CHAPTER 3
  661.  
  662.                    SOFTWARE PRODUCTIVITY INFORMATION
  663.  
  664.  
  665.  
  666.            In this chapter, Texas Instruments reports on  Software  life
  667.       cycle  labor  distribution  (as gathered from our labor collection
  668.       system), productivity (LOC) and experiences with software reuse.
  669.  
  670.       3.1  REUSABILITY OF SOFTWARE
  671.  
  672.            Reusability  of  software  played  a  useful  role   in   the
  673.       development  of  the  NOSC  tools.  Ada software written for other
  674.       projects was imported (in some cases  without  modification)  into
  675.       the  NOSC  tools,  and software written for one tool was sometimes
  676.       used on another.
  677.  
  678.            Some requirements had to be met in order for this reusability
  679.       to  be  feasible  for  this contract (which was only of six months
  680.       duration):
  681.  
  682.        *  The existence of the software had to be known.  There was  not
  683.           time  during  the  project to search for whatever software was
  684.           available  and  then  determine  if  it   was   suitable   for
  685.           application.   Designers/programmers  had  to  know in advance
  686.           that the software was available, what it did, and  if  it  was
  687.           general-purpose  enough  to  be reusable.  A minimum of effort
  688.           had to be expended in order to determine this information.
  689.  
  690.        *  The reliability of  the  software  had  to  be  assured.   The
  691.           designers/programmers  had  to be sure that the software would
  692.           work as advertised.  It was not desirable  to  spend  time  in
  693.           debugging software components which were supposedly "correct."
  694.  
  695.  
  696.            The following are  some  recommendations  for  those  readers
  697.       considering  the  establishment  of  a  repository of Ada software
  698.       components.
  699.  
  700.        *  A small team of individuals should  be  formed  to  act  as  a
  701.           filter  for  the  local  repository.  The team's purpose is to
  702.           examine incoming software, test it, examine its documentation,
  703.           and document it in a standard fashion.
  704. SOFTWARE PRODUCTIVITY INFORMATION                             Page 3-2
  705.  
  706.  
  707.        *  Software for  the  repository  can  come  from  a  variety  of
  708.           sources.   These  include  the  Ada Repository on the SIMTEL20
  709.           host computer of  the  DoD's  Defense  Data  Network,  company
  710.           projects  and contracts, commercial software repositories, and
  711.           individual contributions.
  712.  
  713.        *  The  repository  should  contain  at  least  two  classes   of
  714.           software.   The  first  is  the  software  component, which is
  715.           mainly generic in nature and can be instantiated for a variety
  716.           of  applications.   The second is the software tool, which can
  717.           be used  to  assist  the  software  designer/programmer  in  a
  718.           variety  of ways, including the reduction of his documentation
  719.           overhead  and  the  adoption  of  standards  (with  as  little
  720.           additional  overhead imposed as possible) that aid in creating
  721.           more reusable, maintainable software.
  722.  
  723.        *  The activity of the repository team should be performed before
  724.           a  project  is  undertaken  and  assumed  as overhead (for all
  725.           projects) by the organization.  This overhead investment could
  726.           result  in  substantial  schedule and cost savings in the long
  727.           run, and it has to be viewed as a long-term investment.
  728.  
  729.         Of the software which was reused during the development  of  the
  730.       NOSC  tools,  the  online documentation system (HELP) was the most
  731.       significant.   This  system  was  used  for  both   the   Spelling
  732.       Checker/Corrector  and  Style Checker tools.  Originally developed
  733.       for the AIM (APSE Interative Monitor)  project  at  TI,  the  HELP
  734.       system was imported and adapted to both tools in approximately two
  735.       man-days.  No new development was required, and relatively  little
  736.       redesign was involved.  The size of the HELP system is illustrated
  737.       in the following table:
  738.  
  739.  
  740.       File Name                       Statements    Comments       Lines
  741.  
  742.       HELPINFO_SPEC.ADA                       40          59         146
  743.       HELPINFO_BODY.ADA                       62         104         239
  744.       HELP_SPEC.ADA                           12          27          51
  745.       HELP_BODY.ADA                           42          31         117
  746.       HELP_DIS_ALL.ADA                        17          26          66
  747.       HELP_EXIT.ADA                            5          26          41
  748.       HELP_FIND.ADA                           21          30          86
  749.       HELP_GET.ADA                            25          23          81
  750.       HELP_INIT.ADA                           69          67         238
  751.       HELP_ME.ADA                             99          76         328
  752.       HELP_MENU.ADA                           47          44         165
  753.       HELP_PROMPT.ADA                         27          34         110
  754.       HELP_RESET.ADA                           4          25          39
  755.       HELP_TEXT.ADA                            7          23          43
  756.       HELP_FILE_SPEC.ADA                      11          22          37
  757.       HELP_FILE_BODY.ADA                      33          25          95
  758.                                             ====        ====        ====
  759.       Totals =>                              521         642        1882
  760.  
  761. SOFTWARE PRODUCTIVITY INFORMATION                             Page 3-3
  762.  
  763.  
  764.         This is significant in that several manmonths worth of work  was
  765.       saved via reuse.          The   HELP   system,  however,  was  not
  766.       originally designed with reuse in mind.  Some  components  of  the
  767.       NOSC  tools  designed  by  TI  were designed with the intention of
  768.       reusing them, and, as  was  observed  by  reusing  the  components
  769.       designed  for  one  tool  in  other tools, the overhead of reusing
  770.       these components in  the  future  will  be  even  less  than  that
  771.       observed  with  the  HELP system.  Some of the software components
  772.       employed in the NOSC tool designs which were  originally  designed
  773.       for general-purpose use at an earlier time included the following:
  774.  
  775.  
  776.       File Name                       Statements    Comments       Lines
  777.       character_set.ada                      162          34         301
  778.       cline_handler.ada                       20          26          74
  779.       cline_iface.ada                        119         109         317
  780.                                             ====        ====        ====
  781.       Totals =>                              301         169         692
  782.  
  783.  
  784.       3.2  SOFTWARE LIFE CYCLE LABOR DISTRIBUTION
  785.  
  786.            In order that proper  tracking  of  project  hours  could  be
  787.       accomplished, we established labor categories reflective of the SW
  788.       life cycle within our labor reporting system.   As  the  engineers
  789.       advanced  thru  the  life  cycle,  time  was charged to the charge
  790.       number corresponding to the phase.  Analysis of the data indicates
  791.       hours  were  spent  as  follows.  Several numbers in this data may
  792.       appear suspect; this is how the  labor  system  recorded  it;  the
  793.       accuracy  of  this data is subject to the normal problem of humans
  794.       inputting the correct data.
  795.  
  796.  
  797.                           Virtual    Spelling      Style     Batch/Forms
  798.                           Terminal   Corrector    Checker     Generator
  799.                           ========   =========    =======    ===========
  800.       Requirements
  801.       System Spec                           11
  802.       Preliminary Design                   458        416            397
  803.       Users manual          16             100         35             35
  804.       Detailed design      344              40        148            223
  805.       Implementation       634             604        517            559
  806.       Training               8               8         12              8
  807.       Integration                                                      4
  808.       Qaulity Assurance     26
  809.       Testing              594             226        273             79
  810.       Data management        4
  811.       Configuration Mgt      1               3          3              1
  812.       ------------------
  813.       Sub Total           1627            1450       1404           1306
  814.       Program Management    76              76         75             75
  815.       ------------------
  816.       Grand Total         1703            1526       1479           1381
  817.       Manmonths           9.84            8.82       8.58           7.98
  818.  
  819. SOFTWARE PRODUCTIVITY INFORMATION                             Page 3-4
  820.  
  821.  
  822.  
  823.  
  824.            While a manmonth is contractually approximated at 173  hours,
  825.       many hours in excess of an 8 hour day were worked.
  826.  
  827.            Since this program was managed as  1  contract  with  4  task
  828.       elements, program management time was accumulated as an aggregate;
  829.       the hours spent are allocatable to the whole program, not any  one
  830.       tool  in  particular.  Total program management hours was 303.  In
  831.       the above table, these hours were allocated  equally  across  each
  832.       tool.
  833.  
  834.            Requirements and  System  specification  had  little  charges
  835.       because  the  proposals  written for these tools were written with
  836.       the intent that they serve as the requirements and  specifications
  837.       documents
  838.  
  839.            Configuration management  is  low  because  some  of  the  CM
  840.       function  was  handled  by  a support group (not allocated to this
  841.       project) and some was accomplished after the  data  was  extracted
  842.       for  this  report.   In  any case, all Software and documents have
  843.       been CM'd and a retrievable according to standard TI procedures.
  844.  
  845.       3.3  PRODUCTIVITY (LOC)
  846.  
  847.            TI used the PAGER tool from the Ada repository as  a  vehicle
  848.       by which to count Ada statements, comments and total text lines in
  849.       the tools.  This tool considers an Ada statement to be  terminated
  850.       by a semicolon.  As such, a text line can contain one Ada comment,
  851.       one or more Ada statements, or one or more Ada statements  and  an
  852.       Ada comment.
  853.  
  854.            Following is a table indicating  the  lines  of  Ada  source,
  855.       comments,  text  lines  and  testing  code  in  each  of the tools
  856.       written.  Note that in the batch/form generator  and  the  virtual
  857.       terminal,  testing  code had to be written to exercise the various
  858.       interfaces; this code was also written in Ada.
  859. SOFTWARE PRODUCTIVITY INFORMATION                             Page 3-5
  860.  
  861.  
  862.  
  863.                     Virtual     Spelling       Style         Batch/Forms
  864.                     Terminal    Corrector     Checker         Generator
  865.                     ========    =========     =======        ===========
  866.  
  867.       Ada Source:     2421        2743          3189          2869
  868.       Comments:        590        2626          2013          1707
  869.       Text Lines:     6300        9458          9762          8307
  870.  
  871.       Test Source     1218                                     163
  872.       Comments:        155                                     200
  873.       Text Lines:     1762                                    1398
  874.       ---------
  875.       Totals:
  876.         Ada Source:   3639        2743          3189          3032
  877.         Comments:      745        2626          2013          1907
  878.         Text Lines:   8062        9458          9762          9705
  879.  
  880.  
  881.            Any figures regarding lines of code/day must consider the way
  882.       lines  of  code is determined.  Some techiques consider every text
  883.       line in a program to be a line  for  measurement  purpose,  others
  884.       only  count  executable  statements  and exclude comments and data
  885.       definition.  Since there seems to be no universal agreement on the
  886.       proper technique, for the purposes of this report, we will compute
  887.       LOC based on both the total number of text  lines  and  the  total
  888.       number  of Ada source statements.  In all cases, testing code will
  889.       be counted.
  890.  
  891.  
  892.  
  893.                     Virtual     Spelling       Style         Batch/Forms
  894.                     Terminal    Corrector     Checker         Generator
  895.                     ========    =========     =======        ===========
  896.  
  897.       Ada Source:     3639        2743          3189          3032
  898.       manmonths        9.84        8.82          8.55          7.98
  899.       LOC/mm         369.8       311.0         372.98        379.9
  900.       LOC/day         17.2        14.46         17.34         17.67
  901.  
  902.       Text Lines:     8062        9458          9762          9705
  903.       manmonths        9.84        8.82          8.55          7.98
  904.       LOC/mm         819.3      1072.3        1141.75       1216.16
  905.       LOC/day         38.13       49.87         53.10         56.56
  906.  
  907.  
  908.  
  909.            LOC/day assumes 21.5 work days per month.  It should be noted
  910.       that  these  tools did require some Mil-Std documentation, such as
  911.       design specs, test plans/procedures, users manuals.  Where nothing
  912.       was mandated in the CDRL list, internal TI documentation standards
  913.       were used.
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.                                CHAPTER 4
  927.  
  928.          IMPLEMENTING IN THE ADA DEVELOPMENT ENVIRONMENT (ADE)
  929.  
  930.  
  931.  
  932.       4.1  INTRODUCTION
  933.  
  934.            The software written by TI under this contract was written on
  935.       a  Data General MV10000 under the ROLM Ada Development Environment
  936.       (ADE) version 2.2.  This  environment  includes  a  validated  Ada
  937.       compiler,  a  symbolic  debugger, a pretty-printer, and some other
  938.       tools.  This chapter discusses some items of interest  in  working
  939.       under the ADE.
  940.  
  941.       4.2  PERFORMANCE CONSIDERATIONS
  942.  
  943.            Many things may influence performance of developed software.
  944.  
  945.       1.  inherent algorithmic complexity,
  946.  
  947.       2.  quality and size of the compiler-generated object code,
  948.  
  949.       3.  coding techniques,
  950.  
  951.       4.  options specified  to  suppress  certain  boundary  and  range
  952.           checking code when compiling and linking.
  953.  
  954.  
  955.            While developing software in the Ada Development Environment,
  956.       these  performace  consideration  arose.   The  Data  General  Ada
  957.       compiler and linker presently have some significant problems  that
  958.       impact the performance of software compiled and linked using them.
  959.       It is our understanding that DG has plans to remedy many of  these
  960.       problems in upcoming releases.
  961.  
  962.       1.  Static  storage  allocation.   The  DG   Ada   compiler/linker
  963.           generates  one  32-bit  word for every elementary data object.
  964.           In addition  to  requiring  large  amounts  of  storage,  such
  965.           storage   allocation  causes  performance  degradation,  extra
  966.           software to be written, and productivity decreases  as  system
  967.           developers   had  to  determine  storage  allocation  figures,
  968.           interfaces with system services, etc.   Even  boolean  objects
  969.           occupy  1  32-bit word!  Arrays of any kind have a 16-word (32
  970.           bits each) overhead associated with them.  Strings are  stored
  971.           as  an array of characters, each character occupying the upper
  972. IMPLEMENTING IN THE ADA DEVELOPMENT ENVIRONMENT (ADE)         Page 4-2
  973.  
  974.  
  975.           8-bits of a  32-bit  word,  each  array  having  that  16-word
  976.           overhead.
  977.  
  978.                When making calls to system services, strings had  to  be
  979.           packed to pass in, and unpacked when returned.
  980.  
  981.                When performing slice assignment and  passing  slices  as
  982.           parameters,  it  is  expensive  to  move 4 to 32 times as much
  983.           storage around as actually is required.
  984.  
  985.       2.  Dynamic storage allocation.  The Ada run-time support for  Ada
  986.           programs   does   not  recover  lost  storage.   Neither  does
  987.           unchecked_deallocation work.  And, aggregates are  constructed
  988.           from  heap  space  that is not automatically deallocated after
  989.           use.  This caused the storage_error  exception  to  be  raised
  990.           often.
  991.  
  992.       3.  Pragma INLINE.  Performance should be enhanced with the use of
  993.           the  pragma  inline.   However,  we  found  the  debugger  had
  994.           extensive problems when  dealing  with  procedures  that  were
  995.           marked  as  in_line'able.   It  couldn't  recognize  that they
  996.           existed  and   tended   to   make   the   program   completely
  997.           unrecognizable in the debugger.
  998.  
  999.       4.  DG  Tasking.   Performing  an  Input/Output  operation  on   a
  1000.           terminal  causes  not  only the task requesting the operation,
  1001.           but the entire  program  to  block  until  completion  of  the
  1002.           operation.
  1003.  
  1004.       5.  DG System Services.  The System Services  were  for  the  most
  1005.           part  undocumented,  making  discovery  of  how  to access the
  1006.           services  very  difficult.   Access  to   the   services   was
  1007.           compounded  by  the lack of representation specifications that
  1008.           were necessary for using some of the system services.
  1009.  
  1010.       6.  Representation Specifications.  The "optional" Ada feature  of
  1011.           representation specifications was not operational on the DG.
  1012.  
  1013.       7.  Unchecked_conversion.  It is a useful practice  when  building
  1014.           interface  libraries to build on other existing packages.  For
  1015.           example, two specs to consider:
  1016. IMPLEMENTING IN THE ADA DEVELOPMENT ENVIRONMENT (ADE)         Page 4-3
  1017.  
  1018.  
  1019.  
  1020.           PACKAGE early_interface IS
  1021.  
  1022.               TYPE color IS (blue, red, green);
  1023.  
  1024.               PROCEDURE a( a_color : IN OUT color );
  1025.  
  1026.               FUNCTION b RETURN color;
  1027.  
  1028.           END early_interface;
  1029.  
  1030.           -- ----------------------------------
  1031.  
  1032.           PACKAGE newer_interface IS
  1033.  
  1034.               TYPE color IS (blue, red, green);
  1035.  
  1036.               PROCEDURE a( a_color : IN OUT color );
  1037.  
  1038.               FUNCTION my_new_function RETURN positive;
  1039.  
  1040.           END newer_interface;
  1041.  
  1042.           What we have  here  is  a  early  interface  that  contains  a
  1043.           procedure  we  want  to  make  visible in the newer_interface.
  1044.           However we do not want to have  the  spec  of  newer_interface
  1045.           WITH the spec of early_interface and, we do not want to change
  1046.           the early interface.  So, we can define identical named  types
  1047.           and  procedures  in  the  newer_interface providing a "window"
  1048.           into the early interface.
  1049.  
  1050.           In the body of newer_interface we should simply  type  convert
  1051.           the  newer_interface  types into the early_interface types and
  1052.           pass them along.
  1053.  
  1054.           This   cannot   be   done   in   the    DG    Ada    compiler.
  1055.           Unchecked_conversion  does  not  work  and  it will not simply
  1056.           convert using the standard  Ada  syntax.   The  error  message
  1057.           states simply "cannot convert".
  1058.  
  1059.           There can be a severe  performance  penalty  in  converting  a
  1060.           structure  with  arrays and records and combinations of arrays
  1061.           and records.
  1062.  
  1063.  
  1064.       4.3  THE DEBUGGER
  1065.  
  1066.            The debugger proved to be an absolutely  invaluable  tool  in
  1067.       producing  debugged  code.   Among the many capabilities of the DG
  1068.       debugger are:
  1069.  
  1070.        *  evaluating the values of objects and changing them,
  1071. IMPLEMENTING IN THE ADA DEVELOPMENT ENVIRONMENT (ADE)         Page 4-4
  1072.  
  1073.  
  1074.        *  reading debugger scripts from files,
  1075.  
  1076.        *  assigning  a  "logical"  name  to  a  long  identifier  making
  1077.           debugging fast and the chance for typing errors small,
  1078.  
  1079.        *  displaying  the  program  as  reconstructed  from  the   Diana
  1080.           intermediate form (comments removed, code reformatted),
  1081.  
  1082.        *  displaying the calling stack,
  1083.  
  1084.        *  tracing down through pointer references to  the  objects  that
  1085.           they point to,
  1086.  
  1087.        *  examining tasks and their execution characteristics,
  1088.  
  1089.        *  forking back to the  CLI  to  perform  some  operations  (like
  1090.           debugger  script  creation) then coming back into the debugger
  1091.           into the same location that you were originally,
  1092.  
  1093.       With this tool in place, the debugging of Ada programs  became  an
  1094.       absolute  breeze.   It  became  even more important in the testing
  1095.       phase when the errors were insidious and difficult to track down.
  1096.  
  1097.            There were far fewer compiles and links,  and  little  effort
  1098.       was  made  to  include  such  debugging aids as put_line's and the
  1099.       like.  There simply was no need.
  1100.  
  1101.            In summary, an Ada source level  debugger  can  significantly
  1102.       increase the productivity of programmers.
  1103.  
  1104.       4.4  WORKAROUNDS
  1105.  
  1106.            Some basic problems and inconsistencies continue  to  present
  1107.       themselves  in the use of TEXT_IO.  One particular problem is that
  1108.       GET_LINE from the console is not implemented in the same  way  for
  1109.       all  Ada  compilers.   GET_LINE  for DEC Ada, for example, permits
  1110.       editing of the  input  before  it  is  accepted  (delete  previous
  1111.       character,  delete  entire entry, etc, are allowed).  GET_LINE for
  1112.       the Ada in the ROLM ADE does not, and this was "worked around"  by
  1113.       writing   an   implementation  of  GET_LINE  which  had  the  same
  1114.       specification as GET_LINE for TEXT_IO.  This new GET_LINE  used  a
  1115.       SYSDEP (System Dependencies) package for I/O support, so immediate
  1116.       single-character I/O without echo was assured.
  1117.  
  1118.            Yet another workaround was in providing a GET  character  for
  1119.       files  which  had the same specification as the GET in TEXT_IO but
  1120.       returned the ASCII.CR  character  when  the  end  of  a  line  was
  1121.       encountered.   To  complement this, an UNGET was also implemented.
  1122.       GET and UNGET combine very conveniently in parsing algorithms  and
  1123.       greatly   simplify   the  algorithm  in  some  cases  (similar  to
  1124.       algorithms commonly used under  UNIX  which  employ  GET_CHAR  and
  1125.       UNGET_CHAR).
  1126. IMPLEMENTING IN THE ADA DEVELOPMENT ENVIRONMENT (ADE)         Page 4-5
  1127.  
  1128.  
  1129.            The following problems in the DG Ada  compiler  were  "worked
  1130.       around" in order to get the Virtual Terminal software to execute:
  1131.  
  1132.        *  END_ERROR raised incorrectly for text files
  1133.  
  1134.        *  Poor elimination of constraint checking
  1135.  
  1136.        *  /SUPPRESS option raises exceptions
  1137.  
  1138.        *  Placing the specification in  one  library  and  the  body  in
  1139.           another does not work
  1140.  
  1141.  
  1142.       4.5  UNCHECKED DEALLOCATION
  1143.  
  1144.            UNCHECKED_DEALLOCATION is  not  implemented  under  the  ADE.
  1145.       Consequently,  releasing  of  objects  created dynamically was not
  1146.       possible.  To maintain compatability with other Ada compilers  for
  1147.       which   this   feature  is  available,  UNCHECKED_DEALLOCATION  is
  1148.       implemented as a procedure stub which includes  a  comment  as  to
  1149.       what the proper implementation should be.
  1150.  
  1151.       4.6  THE PREDEFINED PACKAGE "CURRENT_EXCEPTION"
  1152.  
  1153.            The Data  General  Ada  Development  Environment  supplies  a
  1154.       package  which  has  proved very useful to debugging.  The package
  1155.       CURRENT__EXCEPTION  supplies  a  value:    CURRENT__EXCEPTION.NAME
  1156.       which  contains  the  description of an exception when it has been
  1157.       raised.  To use this, as a default for the exception handler use:
  1158.  
  1159.       exception
  1160.           when others =>
  1161.               TEXT_IO.PUT("Inside procedure X -- exception: ");
  1162.               TEXT_IO.PUT_LINE(CURRENT_EXCEPTION.NAME);
  1163.               raise;
  1164.  
  1165.            Whenever a program arrives at an  unanticipated  error,  this
  1166.       exception  handler  will  output the name of the exception and its
  1167.       location.  Then it raises the exception and it  should  trace  its
  1168.       exit  path.   This  provides  immediate  debug information without
  1169.       having to add any extra code.
  1170.  
  1171.            The disadvantage of this is that CURRENT__EXCEPTION is not  a
  1172.       standard   package,  and  when  the  source  is  transported,  the
  1173.       CURRENT__EXCEPTION references have to be removed.
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.                                CHAPTER 5
  1187.  
  1188.                         TRANSPORTABILITY ISSUES
  1189.  
  1190.  
  1191.  
  1192.       5.1  INTRODUCTION
  1193.  
  1194.            Texas Instruments Ada Technology Branch has  a  Data  General
  1195.       MV10000  (running  the  ROLM  Ada  Development  Environment) and a
  1196.       Digital Equipment Corporation VAX 11/785 (running  the  beta  test
  1197.       version  of the DEC Ada compiler).  This environment allowed us to
  1198.       examine  first-hand  some   of   the   problems   encountered   in
  1199.       transporting  Ada  software  from one host computer environment to
  1200.       another.
  1201.  
  1202.       5.2  SYSTEM DEPENDENCIES
  1203.  
  1204.            A standard design technique used by TI  on  these  tools  has
  1205.       been  to  evaluate  system  dependencies  in  one  (or  a  set of)
  1206.       packages.   Using  this  technique  significantly   enhances   the
  1207.       transportability of the program (or package or tool set) since all
  1208.       changable items are localized.  System dependencies includes  such
  1209.       things as:
  1210.  
  1211.        *  file names and forms,
  1212.  
  1213.        *  operating system calls,
  1214.  
  1215.        *  underlying implementation assumptions (such as word  size  and
  1216.           representation, floating point accuracy, etc),
  1217.  
  1218.        *  system   specific   Ada   packages   (see   the   section   on
  1219.           current_exception).
  1220.  
  1221.  
  1222.       5.3  DATA GENERAL VS DIGITAL EQUIPMENT
  1223.  
  1224.            The transportation of software between  two  dissimilar  host
  1225.       computers  presents  a  variety  of  problems.   TI ported several
  1226.       pieces of Ada software between the Data General  MV10000  and  the
  1227.       DEC  VAX  11/785,  and the following outlines some of the problems
  1228.       encountered.
  1229. TRANSPORTABILITY ISSUES                                       Page 5-2
  1230.  
  1231.  
  1232.       5.3.1  Physical Transportation Problems
  1233.  
  1234.            The problem of physically transporting the  software  between
  1235.       these  two  machines  was resolved in two ways.  The first was the
  1236.       use of a personal computer as an intermediary, and the second  was
  1237.       the use of magnetic tape as the tranfer medium.
  1238.  
  1239.            TI has its DG MV10000,  its  DEC  VAX  11/785,  and  numerous
  1240.       TVI970  terminals  and  TIPC  computers interconnected via a local
  1241.       area network (LAN).  This  LAN  provided  a  reliable,  noise-free
  1242.       communication  path  which  proved  to  be a useful medium for the
  1243.       transfer of files between  the  two  host  computers.   By  simply
  1244.       typing out a file on the DG and recording the screen displays on a
  1245.       personal computer via a communications program, the file could  be
  1246.       transferred from the DG to the PC.  Once on the PC, the file could
  1247.       then be uploaded to the DEC via the KERMIT file transfer protocol.
  1248.       Due  to  buffer  overflows  on  the  DEC,  uploading  via a "type"
  1249.       transfer is not feasible.  KERMIT cannot (yet)  be  used  on  both
  1250.       ends  because  the only available KERMIT implementation for the DG
  1251.       is written in FORTRAN, and we do not have a  FORTRAN  compiler  on
  1252.       the DG.
  1253.  
  1254.            In performing tape transfers between the  two  machines,  the
  1255.       tape  formats  are incompatable, so a program had to be written to
  1256.       read tapes (only one file allowed per tape)  created  on  the  DG.
  1257.       The  PAGER  tool, which concatenates several files into one larger
  1258.       file, was used to create a file on the DG and then to  disassemble
  1259.       it on the DEC.
  1260.  
  1261.            In both cases, the validity of the file transfer could always
  1262.       be questioned.  PAGER provided a mechanism to check such validity.
  1263.       PAGER can compute a checksum of  the  file  on  the  DG  and  then
  1264.       compute  a checksum of the file after transfer to the DEC.  If the
  1265.       checksums match, the  file  transfer  can  assumed  to  have  been
  1266.       successful.   PAGER  also counts the number of Ada statements, Ada
  1267.       comments, and text lines in the file.
  1268.  
  1269.       5.3.2  Towers Of Hanoi
  1270.  
  1271.            During the development of the NOSC tools, the issue  of  code
  1272.       quality  and  efficiency of generated code came up.  Having a beta
  1273.       test copy of the DEC Ada compiler and an official Data General ADE
  1274.       we  wished to compare them.  The first attempt at this comparision
  1275.       was to compile and execute an  identical  program  on  both.   The
  1276.       program  we  selected was a recursive implementation of the Towers
  1277.       of Hanoi problem.  The program consists of two packages,  a  vt100
  1278.       routine  (83  lines)  and the Towers of Hanoi package (213 lines).
  1279.       The execution of the two programs was observed by running the same
  1280.       program  on  both machines on adjacent terminals.  The VAX version
  1281.       ran significantly faster (at least twice as fast for a tower of  8
  1282.       disks).   This difference could be attributed to ineffeciencies in
  1283.       the implementation of TEXT_IO, in the call handling overhead,  and
  1284.       some of the factors indicated in section 4.2.  Further analysis is
  1285.       necessary.
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.                                CHAPTER 6
  1299.  
  1300.                          TOOL EXTENSION TOPICS
  1301.  
  1302.  
  1303.  
  1304.            This chapter briefly addresses some  additional  ideas  about
  1305.       capabilities which could be included in each of these tools.
  1306.  
  1307.       6.1  INTERACTIVE FORM/BATCH GENERATOR
  1308.  
  1309.       6.1.1  Automated Form Generation
  1310.  
  1311.       An automated means of  generating  forms  was  suggested  by  Col.
  1312.       Whitaker  at our Critical Design Review.  One way of accomplishing
  1313.       this would be to write an Ada declaration  processor  which  would
  1314.       take record type declarations and build the forms which correspond
  1315.       to them.  For instance the types of the individual fields could be
  1316.       used to specify valid values for the fields.
  1317.  
  1318.       6.1.2  Key Mapping Interface
  1319.  
  1320.       Currently  the  mapping  from  terminal  keys  to  internal   Form
  1321.       Generator  functions is handled via the Terminal Capabilities File
  1322.       (TCF) of the Virtual Terminal (VT).  A special entry  named  "fgs"
  1323.       is  used  to  map  key  sequences to VT functions and in turn Form
  1324.       Generator functions.  A  user  interface  could  be  developed  to
  1325.       assist  in the building of the TCF.  This utility could prompt for
  1326.       the key sequence to enable each  internal  function.   This  would
  1327.       then be used to build the entries in the TCF.
  1328.  
  1329.       6.1.3  More Display Renditions
  1330.  
  1331.       Currently the Virtual  Terminal  (VT)  only  supports  Normal  and
  1332.       Reverse  display  renditions.   Logically it could support more as
  1333.       long as the terminal interface  supported  them.   Some  terminals
  1334.       support  highlighted,  underline,  and  blinking fields as well as
  1335.       colors.  An invisible rendition was suggested  by  Col.   Whitaker
  1336.       for entering things like passwords.
  1337.  
  1338.       6.1.4  More Field Types
  1339.  
  1340.       Currently the Form Generator  supports  Alphabetic,  Alphanumeric,
  1341.       Numeric, and Not Limited input character types.  The numeric field
  1342.       types could be enhanced to differentiate between integer, floating
  1343.       point,  and  fixed  point.  General arithmetic expression handling
  1344. TOOL EXTENSION TOPICS                                         Page 6-2
  1345.  
  1346.  
  1347.       could be added.  Numeric fields could be restricted to a range  of
  1348.       values.   Any  field  could  be given a list of valid values which
  1349.       could be entered.
  1350.  
  1351.       6.2  STYLE CHECKER
  1352.  
  1353.       The possible set of style characteristics which could  be  checked
  1354.       is  large.   What seemed to be the most important were included in
  1355.       the delivered Style  Checker,  however  there  were  others  which
  1356.       surfaced  during  the  project and were not able to be implemented
  1357.       within the delivery time.  This notes the most  important  of  the
  1358.       possible extensions to the style.
  1359.  
  1360.       1.  Better Universal checking.   The  current  system  counts  the
  1361.           number  of universals versus all other types.  The measurement
  1362.           of all other types is still vague.  This definition  could  be
  1363.           made  more  specific.   The  universal  checking  for integer,
  1364.           float,  and  boolean  or  enumeration  types  could  be   done
  1365.           individually.
  1366.  
  1367.       2.  Scope.  Processing to determine the scope of part of the input
  1368.           would  add  the  possibility  to  add other style checks.  The
  1369.           first check might be to measure the number  of  local  objects
  1370.           used  in  a  subprogram  vs.  the number of global references.
  1371.           This gives a measurement of independence.  Scoping would  make
  1372.           it  possible  to  do  other  metrics involving object and type
  1373.           declarations.
  1374.  
  1375.       3.  Comment Indentation.  It would be good to include the  ability
  1376.           to check the indentation of comments in more flexible fashion.
  1377.           This  flexibility  is  necessary  since  there  are  so   many
  1378.           different styles of commenting code.
  1379.  
  1380.       4.  Use statement frequency.  It would be desirable to  check  how
  1381.           many  "withed" units are also "used".  Currently the frequency
  1382.           of "uses" is checked independant of the "withs".
  1383.  
  1384.       5.  Pre-defined Type formatting.  It seems  common  for  users  to
  1385.           assume  predefined  types  are reserved words.  The users then
  1386.           treat them as reserved words for the  case  of  the  word  and
  1387.           indentation.   It  might  prove  useful  to  add  a  parameter
  1388.           allowing predefined types to be treated as reserved words.
  1389.  
  1390.       6.  Efficiency.  Another measure of a program is  its  efficiency.
  1391.           This  might  be  a  counterpart  to the transportability style
  1392.           issues.  This would  measure  input  statements,  blocks,  and
  1393.           units  and  judge  the  efficiency  of  the code.  The biggest
  1394.           difficulty here is that the efficiency would be  dependent  on
  1395.           the  compiler and, the efficiency of most compilers is not yet
  1396.           known.
  1397.  
  1398.       7.  Speller.  Interface stubs exist to add in  the  spell-checking
  1399.           tool  to  check  individual  variable  names against a project
  1400.           dictionary.   To  add  this,   the   spell-checking   packages
  1401.           (dictionary)  would have to be obtained, the interfaces should
  1402. TOOL EXTENSION TOPICS                                         Page 6-3
  1403.  
  1404.  
  1405.           be checked again, and a dictionary would have to be completed.
  1406.  
  1407.       8.  Metrics.  Software metrics could apply to style-checking.  The
  1408.           best  approach  would be to obtain an existing metrics package
  1409.           in Ada (or convert one to Ada) and modify the report generator
  1410.           to include the metrics.
  1411.  
  1412.       9.  Parser.  The decision was  made  early  in  the  style-checker
  1413.           development  that  it was not necessary to parse all of Ada to
  1414.           obtain the style results.  In reality, most of  the  cases  of
  1415.           Ada  syntax  has  to  be  handled in one place or another.  It
  1416.           would make this tool more expandable to have  a  complete  Ada
  1417.           parser driving the style checking.
  1418.  
  1419.      10.  Requirements.  It would be useful to use this  tool  to  check
  1420.           several  existing  Ada  projects  and  see what style features
  1421.           prove of most use, and whether any style  features  should  be
  1422.           discarded.   Several  times  in  the  development,  new  style
  1423.           features were added  when  it  became  obvious  that  the  new
  1424.           feature  was  useful.  There should be a continuing search for
  1425.           more applicable style features.
  1426.  
  1427.      11.  Handling incorrect Ada.  The current style-checker depends  on
  1428.           the  input  being  correct Ada code.  It would make the system
  1429.           more usable if it were able to handle erroneous Ada  code  for
  1430.           the input.
  1431.  
  1432.      12.  STYLE  Summary.   It  would  be  useful  if  a   metric   were
  1433.           implemented to summarize the entire style report in one or two
  1434.           numbers.  This would be something  like:   "The  Input  is  98
  1435.           percent compliant with the Ada style."
  1436.  
  1437.  
  1438.       6.3  SPELLING CHECKER
  1439.  
  1440.  
  1441.       Various extensions should be considered for the Spelling Corrector
  1442.       Tool, as indicated below:
  1443.  
  1444.  
  1445.       1.  Since the Master dictionary is quite large (about  45K  words)
  1446.           and  the  present  program  calls  for  it all to be read into
  1447.           memory, other techniques should be considered.  One  technique
  1448.           is  that  during execution, parts of the dictionary are stored
  1449.           in main memory.  When the  dictionary  is  searched  the  main
  1450.           memory  portion  would be searched first.  If the word was not
  1451.           found in the main memory portion a search of the file would be
  1452.           instituted.   When  and  if  the  word was located it would be
  1453.           moved to the main memory dictionary.  Many algorithms for  the
  1454.           search  and  replace functions are available and are generally
  1455.           used in "cache memory" systems.  Such  techniques  would  have
  1456.           significant  effect on the representation and structure of the
  1457.           dictionary files on disk.
  1458.  
  1459. TOOL EXTENSION TOPICS                                         Page 6-4
  1460.  
  1461.  
  1462.       2.  Under the Data General/Rolm Ada Development Environment, which
  1463.           was   the   development   environment   used   on  this  tool,
  1464.           UNCHECKED_DEALLOCATION    is    not     implemented.      Code
  1465.           implementating  a form of garbage collection has been included
  1466.           in the tool but is  commented  out  at  this  time.   Given  a
  1467.           compiler which does implement UNCHECKED_DEALLOCATION, a useful
  1468.           extension would be the inclusion of this code as a  functional
  1469.           entity.  The size of the dictionary structures makes some form
  1470.           of garbage collection mandatory if the tool is to run for  any
  1471.           amount of time in any given environment.
  1472.  
  1473.  
  1474.       3.  The idea of defining an abstract entity  called  a  token  has
  1475.           already been partially implemented.  That is, the Speller team
  1476.           has defined a type called Token Type that is being used by all
  1477.           members  of the team.  However, the internals of that type are
  1478.           made  available  to  all  (i.e.   it  is  not  private).   The
  1479.           possibility  exists of defining this type to be private and of
  1480.           defining the operations that are available for  that  type  in
  1481.           one  package.   This  would ensure that all operations on this
  1482.           type would be performed  consistently.   Operations  that  are
  1483.           candidates for inclusion in this extension are:
  1484.  
  1485.           1.  Equality
  1486.  
  1487.           2.  Less than, Greater than
  1488.  
  1489.           3.  Read a token
  1490.  
  1491.           4.  Write a token
  1492.  
  1493.           5.  Convert a string to a token
  1494.  
  1495.           6.  Convert a token to a string
  1496.  
  1497.           This would also allow for the centralizing of  operations  and
  1498.           ease possible changes to the token definition itself.
  1499.  
  1500.  
  1501.       4.  Reducing storage requirements:  As a corollary to the previous
  1502.           suggestion,  the  problem  of  the  amount of storage could be
  1503.           lessened by the inclusion of a package  that  allows  for  the
  1504.           creation  of  storage through the use of discriminant records.
  1505.           The discriminant used at the creation of each new record  node
  1506.           would  be  the  length of the token string.  This would lessen
  1507.           the  burden  placed  on  the  machine's  storage  capacity  by
  1508.           approximately one-half due to varying word lengths.  There are
  1509.           various dynamic string packages available which use a  similar
  1510.           technique  for  the  storing  of  data.   This extension would
  1511.           necessitate an enhancement of the dynamic string packages  and
  1512.           would involve changing the definition of token.
  1513.  
  1514. TOOL EXTENSION TOPICS                                         Page 6-5
  1515.  
  1516.  
  1517.       5.  The addition of an error  reporting  file  in  the  Dictionary
  1518.           Manager  package  should  also  be considered.  At the present
  1519.           time errors  in  the  file  data  used  for  the  building  of
  1520.           dictionary structures are recognized and the particular record
  1521.           discarded  so  as  not  to  cause  problems  in  the  internal
  1522.           structure.  These errors are not reported.  A dictionary error
  1523.           reporting  file  could  be  created  within  the  package  and
  1524.           maintained  during any given run of the tool.  This file could
  1525.           then be read by the user for  the  purpose  of  verifying  the
  1526.           validity  of  the  dictionary  file.   Complications  could be
  1527.           caused by the various environments and the way that files  are
  1528.           created  and  handled.  This file would necessarily be created
  1529.           with each run.  The decision pertaining to  the  extension  of
  1530.           the  tool  in  this  matter should be made on the basis of the
  1531.           value of the dictionary file information.
  1532.  
  1533.