formations
Besides the definition of the profile’s Stereotypes, XIS2 also includes a ”model-to-model” transformation, the generation of the UserInterfaces View from the Entities View and the Use-Cases View, that is paramount to its ”smart” design approach.
5.4. Defining and Executing ”Model-to-Model” Transformations 89
This transformation is implemented through C# code that performs the following tasks: (1) receive a ModelContents; (2) parse the ModelContents and build a XisModel that contains all the information about the model (obtained by the applications of the XIS2 stereotypes to UML elements); (3) generate the XisUserInterfacesView that cor- responds to the Entities View and Use-Cases View; and (4) generate the UML elements, diagrams and visual information that correspond to the XisUserInterfacesView ob- tained in the previous step.
Listing 5.1 provides an overview of the GenerateUserInterfacesView class, which implements this ”model-to-model” transformation (most of the source-code has been re- moved for text simplicity). The listing contains some particular points that are worth mentioning: (1) the two constants at the beginning of the file, VERTICAL SPACING and HORIZONTAL SPACING, determine the spacing between the visual elements of the diagrams that will be generated; (2) the TransformModel method is responsible for invoking the methods that process the received ModelContents, create the corresponding XisModel, generate the UserInterfaces View, and finally transform the result to UML; (3) the umlModel and the xisModel variables defined in the TransformModel method act as Data Transfer Objects (DTO) [Fowler 03], and are accessed and manipulated by most of the methods in the class; and (4) the TransformUserInterfacesViewToUML method adds a RootNode and two Packages corresponding to the NavigationSpace View and the Interac- tionSpace View, and invokes the methods that transform the XisNavigationSpaceView and the XisInteractionSpaceView to the corresponding UML elements and diagrams. Listing 5.1: Overview of the source-code that implements the XIS2 ”smart” approach transformation. 1 n a m e s p a c e X i s 2 . M o d e l T r a n s f o r m a t i o n s { 2 p u b l i c c l a s s G e n e r a t e U s e r I n t e r f a c e s V i e w { 3 p r i v a t e c o n s t int V E R T I C A L _ S P A C I N G = 1 5 0 ; 4 p r i v a t e c o n s t int H O R I Z O N T A L _ S P A C I N G = 5 0 0 ; 5 6 p u b l i c s t a t i c b o o l V a l i d a t e T r a n s f o r m a t i o n ( 7 M o d e l C o n t e n t s m o d e l ) { ... } 8 9 p u b l i c s t a t i c v o i d T r a n s f o r m M o d e l ( M o d e l C o n t e n t s u m l M o d e l ) { 10 // P e r f o r m v a l i d a t i o n ( to e n s u r e g o o d m o d e l c o n v e r s i o n . . . ) 11 if (! V a l i d a t e T r a n s f o r m a t i o n ( u m l M o d e l ) ) { 12 r e t u r n ; 13 } 14 15 X i s M o d e l x i s M o d e l = new X i s M o d e l () ; 16 17 G e t X i s M o d e l ( um l M o d e l , x i s M o d e l ) ;
18 G e t X i s E n t i t i e s V i e w ( u m l M o d e l , x i s M o d e l ) ; 19 G e t X i s U s e C a s e s V i e w ( u m l M o d e l , x i s M o d e l ) ; 20 21 G e n e r a t e U s e r I n t e r f a c e s ( x i s M o d e l ) ; 22 23 T r a n s f o r m U s e r I n t e r f a c e s V i e w T o U M L ( x i s M o d e l , u m l M o d e l ) ; 24 } 25 26 p r o t e c t e d s t a t i c v o i d T r a n s f o r m U s e r I n t e r f a c e s V i e w T o U M L ( 27 X i s M o d e l parent , M o d e l C o n t e n t s m o d e l ) { 28 R o o t N o d e r o o t N o d e = U M L F a c t o r y . C r e a t e R o o t N o d e () ; 29 r o o t N o d e . N a m e = " G e n e r a t e d M o d e l "; 30 m o d e l . A d d R o o t N o d e ( r o o t N o d e ) ; 31 32 P a c k a g e r o o t N o d e V i e w = U M L F a c t o r y . C r e a t e P a c k a g e () ; 33 r o o t N o d e V i e w . N a m e = " G e n e r a t e d U s e r I n t e r f a c e s V i e w "; 34 r o o t N o d e . A d d V i e w ( r o o t N o d e V i e w ) ; 35 36 P a c k a g e n a v i g a t i o n S p a c e s V i e w = U M L F a c t o r y . C r e a t e P a c k a g e () ; 37 n a v i g a t i o n S p a c e s V i e w . N a m e = 38 " G e n e r a t e d N a v i g a t i o n S p a c e s V i e w "; 39 r o o t N o d e V i e w . A d d O w n e d M e m b e r ( n a v i g a t i o n S p a c e s V i e w ) ; 40 41 P a c k a g e i n t e r a c t i o n S p a c e s V i e w = U M L F a c t o r y . C r e a t e P a c k a g e () ; 42 i n t e r a c t i o n S p a c e s V i e w . N a m e = 43 " G e n e r a t e d I n t e r a c t i o n S p a c e s V i e w "; 44 r o o t N o d e V i e w . A d d O w n e d M e m b e r ( i n t e r a c t i o n S p a c e s V i e w ) ; 45 46 X i s U s e r I n t e r f a c e s V i e w u i V i e w = p a r e n t . X i s U s e r I n t e r f a c e s V i e w ; 47 if ( u i V i e w == n u l l ) { 48 r e t u r n ; 49 } 50 X i s N a v i g a t i o n S p a c e V i e w n a v V i e w = 51 u i V i e w . X i s N a v i g a t i o n S p a c e V i e w ; 52 X i s I n t e r a c t i o n S p a c e V i e w i s V i e w = 53 u i V i e w . X i s I n t e r a c t i o n S p a c e V i e w ; 54 if ( n a v V i e w == n u l l || i s V i e w == n u l l ) { 55 r e t u r n ; 56 } 57 58 T r a n s f o r m I n t e r a c t i o n S p a c e s V i e w T o U M L ( 59 parent , model , i n t e r a c t i o n S p a c e s V i e w ) ; 60 T r a n s f o r m N a v i g a t i o n S p a c e V i e w T o U M L ( 61 parent , model , n a v i g a t i o n S p a c e s V i e w ) ; 62 }
5.4. Defining and Executing ”Model-to-Model” Transformations 91
63 }
64 }
Although a great majority of this source-code is already implemented and functional, there are still some transformation methods and issues that need to be improved; this is why the ProjectIT-Studio still does not offer total support for the XIS2 ”smart” approach.
Chapter 6
Conclusions and Future Work
This chapter is dedicated to the presentation of overall considerations about how this work was conducted and how it has evolved during its development. It is divided in three sections: (1) a discussion of the work developed (including the innovative features of UMLModeler relatively to other UML modeling tools) and improvements that could have been made during the software development process; (2) the planned future work for UMLModeler; and (3) the final conclusions that were originated by this work and the experience of developing in an environment like ProjectIT-Studio.
6.1
Discussion
The UMLModeler is a fundamental component of the ProjectIT-Studio in the context of the ProjectIT approach, because it is its responsibility to: (1) provide a smooth transition from requirements specification to source-code generation; and (2) provide a graphical UML modeling environment that is powerful, but also simple enough so that it does not overwhelm new users.
This plugin offers a range of features that can usually be found in UML modeling tools, and it is expected that many more features are added in future versions. Table 6.1 presents a comparison between the tools analyzed in ”State of the Art”, Chapter 2, and the UMLModeler.
It should be noted that, although some typical features have not yet been developed (such as ”Model Pattern” capture and application), most of those features can easily be implemented, because of the modular architecture of UMLModeler and the ”model manipulation by external plugins” functionality that UMLModeler provides.
An aspect that differentiates UMLModeler from typical UML modeling tools is its support for the graphical definition and application of an UML profile, which is inspired on the widely-accepted mechanism provided by Enterprise Architect [SparxSystems]. The
Table 6.1: Comparison between UMLModeler and the UML tools previously analyzed.
most important changes, introduced by this work, to the Profile mechanism defined by the UML Superstructure [OMG 05b] were: (1) the StereotypeApplication, to overcome the fact that [OMG 05b] does not provide a concrete specification of the relationship between an UML element and a Stereotype that is applied to it; and (2) the ProfilePackage, to enable the segmentation of a Profile in various smaller packages, allowing the use of modeling approaches such as the ”multi-view” approach employed by the XIS2 UML profile. Another advantage of the implemented mechanism is that profiles can be easily exchanged between different instances of ProjectIT-Studio, simply by the copying of the file that contains the profile’s definition.
Another aspect that differentiates UMLModeler from other tools is its support for model manipulation by external entities. This mechanism allows developers to easily provide transformation operations, which can process and manipulate UML models for any number of purposes (e.g., the generation of the UserInterfaces View, in the case of XIS2 [Silva 07]); it also allows developers to provide validation code, which contributes to avoid potential errors in transformations and make the development of a model a dynamic process (because transformations only become available after certain conditions are met by the UML model). However, this mechanism could also be simpler, by providing a set of ”model-to-model” transformation primitives to be used by the transformation operations