Abstract:
A computer method and system preserves derived union constraints and enforces the same in generated target code. The method includes (a) providing a model element having one or more derived union properties, (b) tracking derived union constraints from the derived union properties of the model element, and (c) interpreting the tracked derived union constraints and generating therefrom an implementation that enforces the derived union constraint. Tracking may be by annotating the model element accordingly.

Description:
CROSS REFERENCE TO RELATED APPLICATION(S) 
       [0001]    This application is a continuation of U.S. application Ser. No. 10/975,780, filed Oct. 28, 2004. The entire teachings of the above application(s) are incorporated herein by reference. 
     
    
     BACKGROUND OF THE INVENTION 
       [0002]    With the proliferation of software products and services, attempts have been made to codify and/or standardize the designing of software and software architecture. Examples include: 
         [0003]    The Booch Method and Modeling Language (see “Object Oriented Analysis and Design” by Grady Booch); 
         [0004]    James Rumbaugh and associates&#39; Object Modeling Technique (OMT); 
         [0005]    the Object Oriented Software Engineering (OOSE) method by Ivar Jacobson; and 
         [0006]    the Unified Modeling Language (UML) which combines the foregoing and industry best practices. 
         [0007]    The UML is a visual modeling language (with formal syntax and semantics) for communicating a model or conceptionalization. Thus the modeling language specification specifies modeling elements, notation and usage guidelines and not order of activities, specification of artifacts, repository interface, storage, run-time behavior and so forth. In general, at the modeling level a “problem” is posed in terms of a customer&#39;s needs and requirements and may be referred to as the business problem system. The software designer develops a “solution” software product and or service that addresses the problem. The UML syntax enables software designers to express (specify and document) the subject problems and solutions in a standardized manner, while the UML semantics enable knowledge about the subject system to be captured and leveraged during the problem solving phase. See “UML in a Nutshell” by Simon Si Alhir, published by O&#39;Reilly &amp; Associates, September 1998. As such, the UML enables the sharing of information (including prior solution portions) and extension (without reimplementation) of core object oriented concepts (analysis and design) during the iterative problem-solving process for designing software products. 
         [0008]    A property in UML 2.0 can be marked as being a derived union. The collection of values denoted by the property in some context is derived as the strict union (superset) of all the values denoted, in that context, by properties that subset it. A derived property is identified as a union with a union constraint on the supersetting property. 
         [0009]    The Rose model for UML 2.0 contains many attributes and associations that are constrained to be derived unions. There are, however, no known mechanisms for generating Java code that enforces these constraints. The Eclipse Modeling Framework (EMF) can be used to generate Java code from a Rose model, but provides no automated support for processing derived unions. Indeed, since all such properties are derived, the EMF discards these properties altogether. Even if these properties were retained, the constraint information is discarded by EMF during code generation. 
       SUMMARY OF THE INVENTION 
       [0010]    The present invention overcomes the above limitation and provides a mechanism for generating target code (e.g. Java) that enforces derived union constraints. 
         [0011]    In one embodiment, a computer method for enforcing derived union constraints includes the steps of: 
         [0012]    providing a model element having one or more derived union properties; 
         [0013]    tracking derived union constraints from the one or more derived union properties of the model element; and 
         [0014]    interpreting the tracked derived union constraints and generating therefrom an implementation that enforces the derived union constraint. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0015]    The foregoing and other objects, features and advantages of the invention will be apparent from the following more particular description of preferred embodiments of the invention, as illustrated in the accompanying drawings in which like reference characters refer to the same parts throughout the different views. The drawings are not necessarily to scale, emphasis instead being placed upon illustrating the principles of the invention. 
           [0016]      FIG. 1  is a schematic illustration of a non-list derived union property “namespace”. 
           [0017]      FIG. 2  is a schematic illustration of the derived union of  FIG. 1  subsetted by the “class” property. 
           [0018]      FIG. 3  is a schematic illustration of a list derived union property “ownedElement”. 
           [0019]      FIG. 4  is a schematic illustration of the derived union of  FIG. 3  subsetted by the properties “ownedMember”, “elementImport” and “packageImport”. 
           [0020]      FIG. 5  is a block diagram of a preferred embodiment. 
           [0021]      FIG. 6  is a schematic view of a computer environment in which the principles of the present invention may be implemented. 
           [0022]      FIG. 7  is a block diagram of the internal structure of a computer from the  FIG. 6  computer environment. 
           [0023]      FIG. 8  is a schematic illustration of computer systems implementing methods of the present invention. 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0024]    A description of preferred embodiments of the invention follows. 
         [0025]    Since it would be desirable to generate code that in some way reflects derived union constraints, the present invention records information about derived union properties as constraints. The present invention records this information in the form of annotations on a code generation model. Such properties are made non-changeable, transient, volatile, and non-containment, and corresponding overriding operations are created on classes that contain subsetting properties for the derived unions. Java templates are used to automatically generate code for these operations based on the annotations. The generated comments for the methods associated with these operations indicate for which properties the operation represents a superset, and code is generated for the bodies of these methods, as described below. 
         [0026]    There are a couple of scenarios to consider with respect to derived unions. First, consider the case of a non-list derived union. Shown in  FIG. 1  is an example. 
         [0027]    There is shown a class called “NamedElement”  15  with two properties—“name” and “/qualifiedName”. The latter (/qualifiedName) has a derived value which is computed on demand (in real time), as indicated by the forward slash prefix. 
         [0028]    A Namespace object  13  is a type of NamedElement  15  (i.e., is an instance of the class  15 ). The relationship or associations between Namespace  13  and NamedElement  15  model elements (objects) are indicated at  17  and include certain properties  19   a,b  of Namespace  13 . Each of these properties  19  is a derived union of a respective set of values indicated between curly brackets. The constraint label (or flag) ‘union’ is also indicated in the curly brackets. 
         [0029]    The “ 0 .. 1 ” in  FIG. 1  indicates a multiplicity  27  on the relationship  17 . So the indicated number (multiplicity  27 ) of the Namespace objects  13  can be related to a given NamedElement object  15 . 
         [0030]    Similarly cardinality  29  of the relationship  17  is represented by an asterisk and has a value indicating the number of NamedElement objects  15  related to a given Namespace  13  instance. 
         [0031]    The derived unions (i.e., sets of values) and valid values for multiplicity  27  (and cardinality  29 ) of a relationship  17  are constraints on that relationship (association between objects  13 ,  15 ). Further, if Namespace object  13  is related to other instances/objects, then these other instances/objects inherit these constraints. 
         [0032]    In  FIG. 2 , property “namespace”  19   b  of  FIG. 1  is subsetted by the “class” property  21  in the relationship between Property object  23  and Class object  25 . In this context, a subset of the values of namespace  19   b  (defined in  FIG. 1  as a derived union) is used as the values of class property  21 . 
         [0033]    In the present invention, contents of the curly brackets (i.e., the derived union constraints) are traversed and maintained as annotations on a subject model element instead of being parsed out as in the prior art. As illustrated in  FIG. 5 , in the preferred embodiment, a subject Rose model is used and is the basis for a code generation model  61  of interest, i.e., the software product model being designed. The Rose model for  61  provides support for initially capturing the constraints denoted in curly brackets. The present invention records in the form of annotations  59  in respective parts of the code generation model  61  constraint information for each derived union property (generally  57 ) of respective model elements  67 . Next the present invention employs EMF to generate JAVA code (or the like) from the annotated code generation model  61 ,  59  in a manner that supports processing derived unions. In particular, the invention EMF processing  63  interprets derived union constraint information and keeps track of derived union (originally curly bracketed) items using the annotation entries  59 . The resulting EMF  63  output is an API (e.g., in an object oriented programming language)  65  that enforces derived union constraints. 
         [0034]    In the case of subsetted properties, corresponding overriding operations are created on classes that contain subsetting properties for the derived unions. Java templates are used to automatically generate code for these operations based on the annotations  59 . The generated comments for the methods associated with these operations indicate for which properties the operation represents a superset, and code is generated for the bodies of these methods. 
         [0035]    For purposes of illustration and not limitation, the present invention generates code for the getNamespace( ) operation on the PropertyImpl class (created to override the implementation inherited from its parent) that resembles the following: 
         [0000]    
       
         
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 if (null != getClass_( ) ) { 
               
               
                   
                   return (Namespace) getClass_( ); 
               
               
                   
                 } 
               
               
                   
                 if (null != getOwningAssociation( ) ) { 
               
               
                   
                   return (Namespace) getOwningAssociation( ); 
               
               
                   
                 } 
               
               
                   
                 if (null != getDatatype( ) ) { 
               
               
                   
                   return (Namespace) getDatatype( ); 
               
               
                   
                 } 
               
               
                   
                 return super.getNamespace( ); 
               
               
                   
                   
               
             
          
         
       
     
         [0036]    Now consider the case of a list derived union. For example, the ownedElement property  31  of the Element class  35  is a derived union, as shown in  FIG. 3 . That is, the property  31  name is preceded with a slash (“/”), and indicated between curly brackets is the ‘union’ constraint  33 . Further, the “ownedElement”  31  derived union is subsetted by, for example, the ownedMember (also a derived union), elementImport, and packageImport properties  43 ,  45 ,  47  of the Namespace class  41 , shown in the class diagram of  FIG. 4 . Thus objects of the Namespace class  41  inherit from the properties “namespace”  39  (also a derived union) and “ownedMember”  43 , the respective derived union and subsets constraints. The “ownedElement”  31  part of these constraints includes its own derived union constraint  33  as discussed in  FIG. 3  above and as used here is a nested derived union  33 . 
         [0037]    Similarly, property elementImport  45  and property packageImport  47  each has a nested derived union constraint due to subsetted ownedElement  31 . 
         [0038]    The present invention thus not only maintains annotations  59  ( FIG. 5 ) of the contents between curly brackets for derived unions  57  but also includes any nested derived union data. Such a superset (multiple level inclusive) list of annotations  59  represents the derived union constraints of interest. The preferred embodiment employs EMF  63  to interpret these derived union constraints (including nested ones) from recorded annotation entries  59  and generate a corresponding API  65  that enforces them. An example code generation follows. 
         [0039]    The preferred embodiment generates code for the getOwnedElement( ) operation on the NamespaceImpl class (created to override the implementation inherited from its parent) that resembles the following: 
         [0000]    
       
         
               
               
             
           
               
                   
                   
               
             
             
               
                   
                   Set union = new HashSet( ); 
               
               
                   
                   union.addAll(super.getOwnedElement( ) ); 
               
               
                   
                   union.addAll(getOwnedMember( )); 
               
               
                   
                   union.addAll(getElementImport( ) ); 
               
               
                   
                   union.addAll(getPackageImport( ) ); 
               
               
                   
                   return new EcoreEList.UnmodifiableEList(this, 
               
               
                   
                 Uml2Package.eINSTANCE.getElement_OwnedElement( ), 
               
               
                   
                 union.size( ), union.toArray( ) ); 
               
               
                   
                   
               
             
          
         
       
     
         [0040]      FIG. 6  illustrates an example computer environment in which the present invention operates. Client computer(s)  50  and server computer(s)  60  provide processing, storage, and input/output devices executing application programs and the like. Client computer(s)  50  can also be linked through communications network  70  to other computing devices, including other client computer(s)  50  and server computer(s)  60 . Communications network  70  can be part of the Internet, a worldwide collection of computers, networks, and gateways that currently use the TCP/IP suite of protocols to communicate with one another. The Internet provides a backbone of high-speed data communication lines between major nodes or host computers, consisting of thousands of commercial, government, educational, and other computer networks, that route data and messages. In another embodiment of the present invention, the methods are implemented on a stand-alone computer. In either network or standalone, the invention output software design and models (API&#39;s) are sharable and reusable among users. 
         [0041]      FIG. 7  is a diagram of the internal structure of a computer (e.g., client computer(s)  50  or server computers  60 ) in the computer system of  FIG. 6 . Each computer contains system bus  79 , where a bus is a set of hardware lines used for data transfer among the components of a computer. Bus  79  is essentially a shared conduit that connects different elements of a computer system (e.g., processor, disk storage, memory, input/output ports, network ports, etc.) that enables the transfer of information between the elements. Attached to system bus  79  is I/O device interface  82  for connecting various input and output devices (e.g., displays, printers, speakers, etc.) to the computer. Network interface  86  allows the computer to connect to various other devices attached to a network (e.g., network  70  of  FIG. 6 ). Memory  90  provides volatile storage for computer software instructions used to implement an embodiment of the present invention (e.g., EMF code and Rose models of subject Program Routines  92  and Data  94 ). Disk storage  95  provides non-volatile storage for computer software instructions and data used to implement an embodiment of the present invention. Central processor unit  84  is also attached to system bus  79  and provides for the execution of computer instructions. 
         [0042]    Referring now to  FIG. 8  illustrated is another computer system  10  embodying the present invention techniques mentioned above. Generally, computer system  10  includes digital processor  12  in which subject modeling language and EMF code  20  are utilized. Input means  14  provides user commands, selections (generally communication) to computer system  10 . 
         [0043]    Responsive to input means  14  is user interface  22 . User interface  22  receives user input data from input means  14  and provides input data for processing and manipulation at  20 . The methods of the invention are implemented at  20  for designing Application Program Interfaces that enforce derived union constraints in JAVA, UML, EMF and the like which are output at  16 . Output  16  may be a display monitor, printer or other computer. 
         [0044]    In one embodiment, computer program product  80 , including a computer readable medium (e.g., a removable storage medium such as one or more DVD-ROM&#39;s, CD-ROM&#39;s, diskettes, tapes, etc.) provides at least a portion of the software instructions at  20  and/or user interface  22 . Computer program product  80  can be installed by any suitable software installation procedure, as is well known in the art. In another embodiment, at least a portion of the software instructions may also be downloaded over a wireless connection. Computer program propagated signal product  83  embodied on a propagated signal on a propagation medium (e.g., a radio wave, an infrared wave, a laser wave, a sound wave, or an electrical wave propagated over a global network such as the Internet, or other network(s)) provides at least a portion of the software instructions at  20  and/or user interface  22 . 
         [0045]    In alternate embodiments, the propagated signal is an analog carrier wave or digital signal carried on the propagated medium. For example, the propagated signal may be a digitized signal propagated over a global network (e.g., the Internet), a telecommunications network, or other network. In one embodiment, the propagated signal is a signal that is transmitted over the propagation medium over a period of time, such as the instructions for a software application sent in packets over a network over a period of milliseconds, seconds, minutes, or longer. In another embodiment, the computer readable medium of computer program product  80  is a propagation medium that the computer system  10  may receive and read, such as by receiving the propagation medium and identifying a propagated signal embodied in the propagation medium, as described above for computer program propagated signal product  83 . 
         [0046]    Generally speaking, the term “carrier medium” or transient carrier encompasses the foregoing transient signals, propagated signals/medium, storage medium and the like. 
         [0047]    While this invention has been particularly shown and described with references to preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the scope of the invention encompassed by the appended claims. 
         [0048]    For example, the model interpreter  63  may be implemented in UML, EMF and other modeling languages. The resulting API code (generated implementation)  65  may be in Java, UML, EMF, XML and the like.