Abstract:
A plurality of program components, which do not have matching interfaces, are combined together automatically to generate a larger new program. An interface specifications&#39; database registers the interface specifications corresponding to each of the program components. A program transformation rule memory stores transformation rules for controlling the reconciliation of the non-matching interface specifications of the program components. A data type memory stores data type transformation rules for reconciling non matching data specifications. A mediating program generator detects a mismatch of the interface specifications between at least two program components which are being combined and generates a mediating program in accordance with the program transformation rule and the data type transformation rule which mediating program enables the two programs and their data to communicate. A components composer generates the larger new program from the program components in the program components&#39; database and the generated mediating program.

Description:
BACKGROUND OF THE INVENTION 
     (1) Field of the Invention 
     The present invention relates to a program composing or synthesizing, method and apparatus for composing a program by connecting a plurality of program components, and more particularly to a program composing method and apparatus for composing a program from a plurality of program components having different interfaces. 
     (2) Description of the Related Art 
     An apparatus for composing a program by connecting a plurality of program components is known. As shown in FIG. 2, this apparatus is provided with a program components&#39; database 1 for storing program components and an interface specifications&#39; database 2 for storing component specification information (hereinafter called interface specification information) corresponding to rules of how program components are used. A plurality of program components are selected from the program components&#39; database, and corresponding interface specifications are selected from the interface specifications&#39; database in accordance with the rules stored in the header fields of the selected program components, to thereby compose a new program 8. 
     Such a program components composing apparatus is described, for example, in JP-A-1-94431. 
     SUMMARY OF THE INVENTION 
     Such a conventional apparatus cannot compose a program unless the interfaces of program components have a perfect match or integrity therebetween. Without a perfect match, a user is required to manually modify program components so as to obtain a match between interfaces and then register the modified program components and interface specifications. 
     A &#34;perfect match&#34; between interfaces means that (a) program components&#39; connection mechanisms, such as &#34;procedure call&#34; and &#34;message communications&#34; for transfer of control codes and data between program components are the same, (b) target &#34;procedure names&#34; in &#34;procedure call&#34; are the same, or target &#34;message text names (target names)&#34; in &#34;message communications&#34; are the same, and (c) the numbers and orders of &#34;procedure arguments&#34; used in &#34;procedure call&#34; are the same, or the numbers and orders of &#34;message parameters&#34; used in &#34;message communications&#34; are the same. 
     A work of modifying program components to obtain an interface match imposes a large burden on programmers (users). 
     It is an object of the present invention to provide a program composing or synthesizing apparatus and method capable of composing program components even if there is a mismatch between the interfaces of the plurality of selected program components. 
     In order to achieve the above object, a program composing apparatus of the present invention comprises a first storage unit for storing a transformation rule for a part (connection mechanism of interface) of each program component for transfer of control codes and data, a second storage unit for storing a transformation rule for a parameter data type, means responsive to a mismatch between the interfaces of program components to be composed, for obtaining a match between the interface specifications of the program components while referring to the first and second storage units, and generating a mediating program which transforms a mismatched interface into a matched interface, and means for composing the mediating program and a plurality of program components. 
     According to a preferred embodiment of the present invention, the program components composing apparatus comprises a storage unit for storing a program components&#39; database 1 which registers therein a plurality of program components, a storage unit for storing an interface specifications&#39; database 2 which registers therein the interface specifications of the program components, a storage unit for storing a transformation rule 3 for a connection mechanism part of each interface, a storage unit for storing a transformation rule 4 for a data type in each interface, a mediating program generator 5 for generating a mediating program 6 which obtains a match between interface specifications in accordance with the connection mechanism transformation rule and data type transformation rule, and a components&#39; composer 7 for composing a new program from program components registered in the program components&#39; database and the generated mediating program. 
     With the above arrangement of the present invention, even if the interfaces of program components to be composed are mismatched to each other, they are made matched using a connection mechanism transformation rule and data type transformation rule, and a desired composed program can be obtained without manually modifying program components. 
     The foregoing and other objects, advantages, manner of operation and novel features of the present invention will be understood from the following detailed description when read in connection with the accompanying drawings. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a diagram showing the structure of a program components composing apparatus embodying the present invention; 
     FIG. 2 is a diagram showing the structure of a conventional program components composing apparatus; 
     FIG. 3, consisting of FIGS. 3(a) to 3(d), shows examples of syntactic rules of interface specifications of program components; 
     FIG. 4, consisting of FIGS. 4(a) to 4(d), shows examples of mechanism transformation rules; 
     FIG. 5, consisting of FIGS. 5(a) to 5(d) shows supplemental diagrams illustrating the mechanism transformation rules; 
     FIG. 6 shows an example of a data transformation rule; 
     FIG. 7 shows another example of the data transformation rule; 
     FIG. 8 is a flow chart showing the procedure to be executed by a mediating program generator; 
     FIG. 9, consisting of FIGS. 9(a) to 9(d), shows an example of transformation of interface specifications to obtain a match therebetween; 
     FIG. 10 is a diagram showing the structure of a program components composing apparatus which allows to use a composed program as a new program component; 
     FIG. 11 is a flow chart showing the procedure to be executed by a mediating program generator of the program components composing apparatus which allows to use a composed program as a new program component; and 
     FIG. 12 is a flow chart showing the procedure to be executed by a program component register of the program components composing apparatus which allows to use a composed program as a new program component. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     Embodiments of the present invention will be described with reference to the accompanying drawings. 
     FIG. 1 shows the structure of an embodiment of the present invention. Reference numeral 1 represents a program components&#39; database for storing a plurality of program components to be composed. Numeral 2 represents an interface specifications&#39; database for storing interface specifications of respective program components stored in the program components&#39; database. Numeral 3 represents mechanism transformation rules for interfaces which rules are used for transformation between a plurality of types of connection mechanisms of program components, such as &#34;procedure call&#34; and &#34;message communications&#34;. Numeral 4 represents data type transformation rules for interface parameters which rules are used, when composing program components, in judging whether data types can be transformed. Numeral 5 represents a mediating program generator for mediating program components. The mediating program generator 5 checks a match between interface specifications, supplied from the interface specifications&#39; database 2, of program components to be composed. If there is a mismatch between the program specifications, the interfaces are modified so as to obtain a match, using a mediating program 6 for transforming mismatched interfaces into matched interfaces, in accordance with the mechanism transformation rule 3 and data type transformation rule 4. Numeral 7 represents a components&#39; composer which generates a program 8 by composing a plurality of program components supplied from the program components&#39; database 1, by using the generated mediating program 6. 
     FIG. 3 shows examples of syntactic rules of interface specifications of program components. In FIG. 3, parameters and the like in [. . . ] can be omitted, parameters and the like in {. . . } can be repeated, and parameters and the like in (. . . |. . . ) are selectively used. For example, parameters A and B in (A|B) are selectively used. 
     &#34;in&#34;, &#34;out&#34;, and &#34;update&#34; indicate how an argument is used, namely, &#34;in&#34; means an argument is used only for input, &#34;out&#34; means an argument is used only for output, and &#34;update&#34; means an argument is used both for input and output. The interface specifications of program components stored in the interface specifications&#39; database 2 are described using such syntactic rules. 
     FIGS. 4(a) to 4(d) show examples of mechanism transformation rules 3. FIGS. 5(a) to 5(d) are supplemental diagrams illustrating the mechanism transformation rules. A mechanism transformation rule is a rule for generating a mediating program 6 from the syntactic rules of interface specifications of a plurality of program components to be composed. 
     FIG. 4(a) shows a mediating program to be generated for the case in which one program component to be composed has an interface specification of &#34;procedure call&#34; and the other program component to be composed has an interface specification of &#34;message communications&#34;. This mediating program defines a virtual procedure &#34;callee&#34; for receiving &#34;procedure call&#34;, within this procedure &#34;callee&#34;, a message is sent and received. The parameters of &#34;message send&#34; include an output only argument and an input/output argument, and the parameters of &#34;message receive&#34; include a return value, an input only argument, and an input/output argument. In the above manner, as shown in FIG. 5(a), there is generated a mediating program 52a for transforming &#34;procedure call&#34; into &#34;message send/receive&#34; respectively of the interface specifications of program components 51a, while referring to the mechanism transformation rule 3 shown in FIG. 4(a) and the interface specifications of the program components. 
     FIG. 4(b) shows a mediating program to be generated for the case in which one program component to be composed has an interface specification of &#34;message communications&#34; and the other program component to be composed has an interface specification of &#34;procedure call&#34;. This mediating program receives a transmitted message with a &#34;message name s&#34;, executes &#34;procedure call&#34;, and sends the results as a message with a &#34;message name r&#34;. In the above manner, as shown in FIG. 5(b), there is generated a mediating program 52b for transforming &#34;message communications&#34; into &#34;procedure call&#34; respectively of the interface specifications of program components 51b, while referring to the mechanism transformation rule 3 shown in FIG. 4(b) and the interface specifications of the program components. 
     FIG. 4(c) shows a mediating program to be generated for the case in which one program component to be composed has an interface specification of &#34;procedure define&#34; and the other program component to be composed has an interface specification of &#34;message communications&#34;. This mediating program receives a transmitted message with a &#34;message name r&#34;, executes &#34;procedure call&#34;, and sends the results of a message with a &#34;message name s&#34;. In the above manner, as shown in FIG. 5(c), there is generated a mediating program 52c for transforming &#34;procedure define&#34; into &#34;message communications&#34; respectively of the interface specifications of program components 51c, while referring to the mechanism transformation rule 3 shown in FIG. 4(c) and the interface specifications of the program components. 
     FIG. 4(d) shows a mediating program to be generated for the case in which one program component to be composed has an interface specification of &#34;message communications&#34; and the other program component to be composed has an interface specification of &#34;procedure define&#34;. This mediating program defines a virtual procedure &#34;callee&#34; for receiving &#34;procedure call&#34;. Within this virtual procedure &#34;callee&#34;, a message with a &#34;message name r&#34; is sent and a message with a &#34;message name s&#34; is received. In the above manner, as shown in FIG. 5(d), there is generated a mediating program 52d for transforming &#34;message communications&#34; into &#34;procedure define&#34; respectively of the interface specifications of program components 51d, while referring to the mechanism transformation rule 3 shown in FIG. 4(d) and the interface specifications of the program components. 
     FIGS. 6 and 7 show examples of data type transformation rules. The data type transformation rules defined as shown in FIGS. 6 and 7 are rules applied between two data types &#34;month-day-year&#34; and &#34;year-day&#34;. In the data type &#34;month-day-year&#34;, &#34;month-day-year.month&#34; represents each month: January, February . . . December, and &#34;month-day-year.day&#34; represents a data. In the data type &#34;year-day&#34;, &#34;year-day.day&#34; represents the total number of days as counted from January 1. For example, if &#34;year-day.day&#34; is 35, then it stands for February 4 which in the data type &#34;month-day-year&#34; becomes &#34;month-day-year.month&#34;=2 and &#34;month-day-year.day&#34;=4. 
     The first row of FIG. 6 indicates that &#34;year-day&#34; can be transformed into &#34;month-day-year&#34;, and the second and following rows shown the transformation procedure. The transformation rule shown in FIG. 7 defines transformation from &#34;month-day-year&#34; to &#34;year-day&#34;. 
     The mediating program generator 5 checks a match between the interface specifications of program components to be composed. If there is a mismatch, the mediating program generator 5 transforms mismatched interface specifications into matched interface specifications, using the mechanism transformation rules 3 and data type transformation rules 4. During this transformation procedure, the interface specifications held by the mediating program generator are called &#34;present specifications&#34;. The procedure of interface matching will be described with reference to the flow chart of FIG. 8. A plurality of program components may sometimes be composed, and each program component may sometimes have a plurality of interfaces. In such a case, pairs of the interfaces are sequentially processed to be matched. For the simplicity of description, in the following embodiments, the interface matching procedure between two interfaces of two program components will be described. One of a pair of two interfaces should serve as a receptor of action from the other interface. For example, an interface of &#34;procedure define&#34; or &#34;message receive&#34; is a receptor of its counterpart &#34;procedure call&#34; or &#34;message send&#34;. In the following, the interface serving as a receptor is called &#34;passive interface&#34;, and its counterpart interface is called &#34;active interface&#34;. The interface specifications of a passive interface and an active interface are called &#34;passive specification&#34; and &#34;active specification&#34;, respectively. 
     FIG. 8 is a flow chart illustrating the procedure to be executed by the mediating program generator. First at step 701 the interface specifications of program components to be composed are derived from the interface specifications&#39; database 2. The derived specifications are present specifications at the initial stage. At step 702 it is checked whether the present specifications are matched to each other. If matched, it is checked at step 791 whether there exist the transformation rules used for the matching. If exist, a mediating program is generated at step 792 and thereafter the procedure is terminated. 
     If the present specifications are not matched, it is checked at step 703 whether the mismatch is a mechanism mismatch. If mechanism mismatch, the mechanism transformation rules 3 are checked at step 710. If the mechanism can be transformed, the present specification is transformed at step 711, and the transformation rule used is registered at step 712 while giving a correspondence to the associated interface specification. Thereafter, the procedure advances to step 704. If the mechanism cannot be transformed, it is judged that matching is impossible, to thereafter terminate the procedure. 
     If the mismatch is not a mechanism mismatch at step 703, it is checked at step 704 if the numbers of parameters are mismatched. If mismatched, the number of parameters of the passive specification of the present specification is compared with the number of parameters of the active specification of the present specification. If the number of parameters of the active specification is greater than that of the passive specification, the present specification is modified at step 721 so as to make the number of parameters of the active specification match that of the passive specification. If the number of parameters of the active specification is less than that of the passive specification, it is judged that matching is impossible, to thereafter terminate the procedure. 
     If the numbers of parameters are not mismatched at step 2-4, it is then checked at step 705 whether the data types are mismatched. In the case of a data type mismatch, data types transformable into those of the present specification are obtained first at step 730 while referring to the data type transformation rules 4. It is checked next at step 731 whether there are data types of parameters of the active specification transformable into the data types of the passive specification. If there are transformable data types, the order of parameters of the active specification are arranged at step 732 to have the same parameter order of the passive specification. The data types of the present specification are transformed at step 733. The transformation rule used is registered at step 734 while giving a correspondence to the associated interface specification, and thereafter the procedure returns to step 702. If the data type cannot be transformed, it is judged that matching is impossible, to terminate the procedure. 
     FIG. 9 shows an example of transformation of interface specifications to obtain a match therebetween. FIGS. 9(a) and 9(b) show the interface specifications of two program components. FIGS. 9(a) shows an active interface specification for calling a procedure &#34;date&#34; without using an argument, and receiving as a return value a &#34;year-date&#34; type data. FIG. 9(b) shows a passive interface specification for receiving a message &#34;current-date&#34; without parameter, and sending a message &#34;today&#34; with a &#34;month-day-year&#34; type parameter. The matching procedure for the interface specifications of FIGS. 9(a) and 9(b) will be described with reference to FIG. 8 by using the mechanism transformation rule of FIG. 4(a) and the data type transformation rules of FIGS. 6 and 7. The interface specifications derived at step 701 are the specifications shown in FIGS. 9(a) and 9(b). These specifications are mismatched to each other (step 702), and the mechanisms are mismatched to each other (step 703) so that the mechanism transformation rules are checked at step 710. Since the transformation rule shown in FIG. 4(a) can be used, the specification shown in FIG. 9(a) is transformed in a specification of FIG. 9(c). The rule of FIG. 4(a) is registered at step 712. Next, at step 704 the numbers of parameters of the present specifications shown in FIG. 9(b) and 9(c) are checked. In this case, the numbers of parameters are the same so that the procedure advances to step 705. The data types of parameters are mismatched between the data type &#34;month-day-year&#34; of the send message of FIG. 9(b) and the data type &#34;year-day&#34; of the receive message of FIG. 9(c). At step 730 transformable data types are obtained from the data type transformation rules shown in FIGS. 6 and 7. It can be known therefore that the data type &#34;month-day-year&#34; can be transformed into the data type &#34;year-day&#34; and, the data type &#34;year-day&#34; into the data type &#34;month-day-year&#34;. Next at step 732 the order of parameters of the active specification is rearranged to have the same order of the passive specification. In this case, there is only one parameter so that the parameter order does not change. Next, at step 733, the data type &#34;month-day-year&#34; is transformed into the data type &#34;year-day&#34;. As a result, the specification of FIG. 9(b) is transformed into a specification of FIG. 9(d). At step 734, the transformation rule of FIG. 7 used at that time is registered. Next, the procedure returns to step 702. In this case, the present interface specifications shown in FIGS. 9(c) and 9(d) are matched to each other so that the procedure advances to step 791. Since the rules shown in FIG. 4(a) and FIG. 7 have been registered, a mediating program is generated at step 792, to thereafter terminate the procedure. 
     In the above-described embodiment, a program is generated from program components already stored in the program components&#39; database 1 and interface specifications&#39; database 2. As an alternative, a generated program may be newly registered in the program components&#39; database 1 and interface specifications&#39; database 2 to reuse it as a new program component. The structure of a program composing apparatus realizing such a function is shown in FIG. 10. In FIG. 10 a mediating program generator 5 outputs a mediating program 6 as well as a matched present specification 9. A program component register 10 registers a program 8 generated by a components&#39; composer 7, and outputs it as a new program component into the program components&#39; database 1. The present specification is registered as an interface specification of the new program component in the interface specifications&#39; database 2. The procedure to be executed by the mediating program generator is shown in FIG. 11. In FIG. 11, the processes from step 701 to step 792 are the same as described with FIG. 8. After step 792, the matched present specification is outputted at step 101. FIG. 12 is a flow chart showing the procedure to be executed by the program component register 10. At step 110 a program 8 generated by the components&#39; composer 7 is registered as a new program component in the program components&#39; database 1, and at step 111 a present specification 9 outputted from the mediating program generator 5 is registered as the interface specification of the new program component in the interface specifications&#39; database 2. 
     According to the present invention, a program can be composed from program components even if they have mismatched interfaces, without manually changing the program components, by generating an interface mediating program using a mechanism transformation rule and data type transformation rule. Furthermore, by registering a generated program as a new program component, it is possible to increase the number of program components and improve a reuse of program components.