Program design by informal English descriptions

Data Types and Software Validation On the Criteria to be Used in Decomposing Systems into Modules On the Design and Development of Program Families A Design Methodology for Reliable Software Systems the KWIC index would be Abstract Data Types and Software Validation On the Criteria to be Used in Decomposing Systems into Modules Abstract Data Types and Software Validation On the Criteria to be Used in Decomposing Systems into Modules On the Design and Development of Program Families On the Design and Development of Program Families On the Design and Development of Program Families A Design Methodology for Reliable Software Systems A Design Methodology for Reliable Software Systems On the Criteria to be Used in Decomposing Systems into Modules On the Design and Development of Program Families A Design Methodology for Reliable Software Systems A Design Methodology for Reliable Software Systems Abstract Data Types and Software Validation A Design Methodology for Reliable Software Systems On the Criteria to be Used in Decomposing Systems into Modules Abstract Data Types and Software ValidationData Types and Software Validation On the Criteria to be Used in Decomposing Systems into Modules Abstract Data Types and Software Validation On the Criteria to be Used in Decomposing Systems into Modules On the Design and Development of Program Families On the Design and Development of Program Families On the Design and Development of Program Families A Design Methodology for Reliable Software Systems A Design Methodology for Reliable Software Systems On the Criteria to be Used in Decomposing Systems into Modules On the Design and Development of Program Families A Design Methodology for Reliable Software Systems A Design Methodology for Reliable Software Systems Abstract Data Types and Software Validation A Design Methodology for Reliable Software Systems On the Criteria to be Used in Decomposing Systems into Modules Abstract Data Types and Software Validation Assume a program that takes a list of titles and produces a KWlC index. An informal solution is: 1. Consider each title in the title list in turn. 2. For each title, consider each word in that title. 3. If the word is not a common word, enter the title into the KWIC index at the position identified by that and perhaps subsequent words. lO.1. The Data Types The common nouns are: TITLE, TITLE_LIST, WORD, COMMON_WORD, KWIC_INDEX, POSITION, THAT_AND_SUBSEQUENT_WORDS Notice that we have listed THAT_AND_SUBSEQUENT_ WORDS as a data type. This is certainly not one of the more obvious types and it was discovered only after a fair amount of analysis. This is an "ugly" data type, but it does characterize, on the level of the problem, the information required to determine where a title fits in a KWIC Index with respect to a given word in the title• We can define the initial data types as: type TrrLE is type TITLE_LIST is type WORD is type COMMON_WORD is type KWIC_INDEX is type POSITION is type THAT_AND_SUBSEQUENT_WORDS is ° ° ~ 10.2. The Objects The objects are: THE_TITLE_LIST; EACH_TITLE, THAT_TITLE, THE_TITLE; (These are used synonymously.) EACH_WORD, THE_WORD, THE_CURRENT_WORD; (These are used synonymously.) THE_KWIC_INDEX; THE_POSITION. So we can make our initial object declarations: THE_TITLE_LIST TITLE_LIST; THE_TITLE TITLE; THE_WORD WORD; THE_KWIC_INDEX KWIC_INDEX; THE_POSITION P o s m o N ; 10.3. The Operators The operators (in the form of Ada subprogram signatures) are: procedure CONSIDER_NEXT_TITLE (NEXT_TITLE : out TITLE; A TrI'LE_LIST : in out TITLE_LIST; MORE_TITLES : out BOOLEAN); Given a TITLE_LIST, sets NEXT_TITLE to the next unscanned TITLE and increments the TITLE_LIST's internal "scan pointer. " Sets MORE_TITLES depending on whether or not an unscanned title has been found in the LIST. procedure CONSIDER_FIRST_TITLE (FIRST_TITLE : out TITLE; A_TITLE_LIST : in out TITLE_LIST; ANY_TITLES : out BOOLEAN); Good practice suggests an initialization "first" operator to complement the "next" operator. The meanings of the parameters are similar• procedure CONSIDER_NEXT_WORD (NEXT_WORD : out WORD; A_TITLE : in out TITLE; MORE_WORDS : out BOOLEAN); Similar to the CONSIDER_NEXT_TITLE operator except that the object scanned is a single TITLE and the object scanned for is a WORD. In addition, titles have a "current word" indicator that is set to the NEXT_ WORD. 892 Communications of the ACM November 1983 Volume26 Number 11 procedure CONSIDER_FIRST_WORD (FIRST_WORD : o u t WORD; A_TITLE : in o u t TRIFLE; ANY_WORDS : o u t BOOLEAN); A "first" WORD operator to complement the "next" WORD operator. function IS_A_COMMON_WORD (A_WORD : WORD) return BOOLEAN; Determines whether the given WORD is a COMMON_WORD. procedure ENTER(A_TITLE : TITLE; A_KWIC_INDEX : KWlC_INDEX; A_POSITION : POSITION); Enters the TITLE into the KWIC_INDEX at the indicated position. function REMAINING_WORDS(A_TITLE : TITLE) return THAT_AND_SUBSEQUENT_WORDS; Returns the sequence of words remaining in the title from the "current word" (see CONSIDER_NEXT_ WORD) to the end of the title. In Ada, the name of a subprogram may not be the same as the name of a data type. function WHICH_POSITION (WORDS : THAT_AND_ SUBSEQUENT_WORDS; A_KWIC_INDEX : KWIC_INDEX) relurn POSITION; Finds the POSITION in the KWIC_INDEX where rifles are indexed under the "current and perhaps subsequent word(s)" in the given TITLE. 10.4 The Control Structure and the Final Solution The control structure is a simple pair of nested loops. They are shown clearly in the final program. The final program consists of two packages and a procedure that uses those packages. One package defines the data types and the operators for WORDs and TITLEs and the other defines the data types and operators for KWIC objects. package TITLES_AND_WORDS is Requirements Data types for dealing with rifles that consist of sequences of words. Conceptual Model The cleanest way to give the conceptual model is to make use of a previously defined, generic package for general sequences. Since generics are not discussed here, we do not give the complete specification. We do assume, though, that title sequences have pointers that may be set and moved. type THAT_AND_SUBSEQUENT_WORDS is private; type TITLE is private; type TITLE_LIST is private; type WORD is private; O p e r a t o r s We do not repeat the descriptions of the operators. They are the same as given earlier. procedure CONSIDER_FIRST_TITLE (FIRST_TITLE : o u t TRIFLE; A_TITLE_LIST : in o u t TITLE_LIST; ANY_TITLES : o u t BOOLEAN); procedure CONSIDER_NEXT_TITLE (NEXT_TITLE : o u t TITLE; A_TITLE_LIST : in o u t TITLE_LIST; MORE_TITLES : o u t BOOLEAN); procedure CONSIDER_FIRST_WORD (FIRST_WORD : o u t WORD; A_TITLE : in out TITLE; ANY_WORDS : o u t BOOLEAN); procedure CONSIDER_NEXT_WORD (NEXT_WORD : o u t WORD; A_TITLE : in out TITLE; MORE_WORDS : o u t BOOLEAN); function REMAINING_WORDS(A_TITLE : TITLE) r e t u r n THAT_AND_SUBSEQUENT_WORDS; e n d TITLES_AND_WORDS; with TITLES_AND_WORDS; use TITLES_AND_WORDS; package KWIC_STUFF is R e q u i r e m e n t s Data types for KWIC indices. C o n c e p t u a l M o d e l Again, no complete conceptual model is given since it too is best described in terms of a generic sequence package. type COMMON_WORD is private; type KWIC_INDEX is private; type POSITION is private; O p e r a t o r s Again, we do not repeat the operator descriptions. function IS_A_COMMON_WORD(A_WORD : WORD) r e t u r n BOOLEAN; procedure ENTER (A_T1TLE : TITLE: A_KWIC_INDEX : KWIC_INDEX; A_POSITION : POSITION); function WHICH_POSITION (WORDS : THAT_WORD_AND_ : SUBSEQUENT_WORDS; A_KWIC_INDEX : KWIC_INDEX) return POSITION;