240 likes | 426 Views
A REFACTORING TOOL FOR DESIGN PATTERNS WITH MODEL TRANSFORMATIONS. Zekai Demirezen Yasemin Topaloğlu Ege University Department of Computer Engineering zekai@mail.ege.edu.tr yasemin.topaloglu@ege.edu.tr. Agenda. Background Design Pattern: A Target for Refactoring
E N D
A REFACTORING TOOL FOR DESIGN PATTERNS WITH MODEL TRANSFORMATIONS Zekai Demirezen Yasemin Topaloğlu Ege University Department of Computer Engineering zekai@mail.ege.edu.tr yasemin.topaloglu@ege.edu.tr
Agenda • Background • Design Pattern: A Target for Refactoring • Pattern Specification and Metamodeling • Transformation MetaModels • XML Metadata Interchange • Tool Architecture • Components of the tool • Transformations • Case Study: Observer Design Pattern • Example MetaModels and Models • Screen Shots • Conclusions NWUML06, 12 June 2006
Refactoring OTHER INPUTS ???? Design Pattern: A Target for Refactoring Design Model with design patterns Design Model NWUML06, 12 June 2006
"from human-readable ……………………to computer-understandable" Pattern Specification NWUML06, 12 June 2006
In order to process models in transformation activities, meta-modeling is required. Meta-modeling defines the rules and the structures of models. Role-based meta-modeling technique is proposed by (France et al,2004) for design pattern meta-modeling. • Structural Pattern Specification(SPS) • Interaction Pattern Specification(IPS) • State Machine Pattern Specification(SMPS) Role-Based Meta-Modelling NWUML06, 12 June 2006
What we want to transform OMG 4 Layer Architecture NWUML06, 12 June 2006
Source Meta-Model defines the models that the transformation will be applied. Transformation Meta-Model defines the transformation rules and the steps. Target Meta-Model defines the output model of the transformation activity. Definition of transformation T: A->B Source Meta-Model Target Meta-Model instanceOf instanceOf instanceOf An application of transformation T(a) = b Model a Model b Transformation Meta-Models NWUML06, 12 June 2006
Source MetaModel Target MetaModel Transformation MetaModel Tool Inputs Design Model with design patterns Design Model NWUML06, 12 June 2006
XML Metadata Interchange(XMI) XMI is a widely used interchange format for sharing objects using XML. Export Import NWUML06, 12 June 2006
Model editor is a standard modeling tool such as Rational Rose that can be used to prepare the application design models. Rule editor is used to prepare the source and the target meta-models Transformation Preparer takes the application model and the source and the target meta-models as inputs and then matches the application model elements with the meta-elements. Transformation machine executes the transformation steps defined in transformation meta-model Tool Architecture Tool Architecture (A. Wagner, 2002) NWUML06, 12 June 2006
Representation Transformer (RT): It transforms the meta-model’s XMI representation to object representations by transforming Transformation Pattern Generator (TPG): This component produces transformation meta-model at run-time by analyzing structural differences between the source and target meta-models Rol-ModelElement Transformer (REM): This component matches the roles with application model elements. Matching activity is a kind of searching process of role’s structural properties in the application model. Transformation Machine(TM): It is the last component that executes the transformation meta-model tasks on the application model. Add, delete and update operations assign the role properties in to the selected model elements Subcomponents of the Tool NWUML06, 12 June 2006
XML Representation-Object Representation Transformation: The source, target and the application models in XMI are transformed into the objects representations. Transformations-1 • Composite Transformation • Transformation Reuse • is defined in Appukuttan et al 2003 NWUML06, 12 June 2006
MetaModel-Model Transformation: The roles constituting the target meta-model are matched with the application model elements and the source meta-model-source model transformation is the result of this matching Transformations-2 NWUML06, 12 June 2006
Transformations-3 • Application Model-Result Application Model Transformation: Model elements in the application model are transformed into the model elements of the target model by processing the steps in the transformation model. Transformation specifications in the transformation machine are applied on the application model in this transformation. NWUML06, 12 June 2006
Transformations-4 • Result Application Model Object Representation-XMI Representation Transformation: This step transforms the result model of the transformation process into the XMI format. Each model element is transformed into the corresponding element in the XMI format NWUML06, 12 June 2006
Overview NWUML06, 12 June 2006
Case Study • We demonstrate the usage of our tool for the Observer[Gamma et al.] pattern. • Observerpattern describes the situation in which a one-to-many dependency between objects is present. • In this case, when one object changes state, all its dependents are notified and updated automatically NWUML06, 12 June 2006
Case Study:Source Meta-Model • Preparing the Observer Source MetaModel Specification • Applicability and motivation sections of the patterns in the catalogue are problem definitions for patterns • In some parts we use stereotypes in order to provide problem semantics. During stereotype usage, we prefer to use universal standard stereotypes. NWUML06, 12 June 2006
Case Study:Target Meta-Model • Preparing Observer Target MetaModel Specification • The target specification is the solution of the design pattern. We use the Class structure and the Participants sections of the GOF Design Pattern catalogue to derive this specification. • Semantic parts of the design pattern target specification are supported by the stereotype usage. NWUML06, 12 June 2006
Case Study: Application of the Tool After the rule definition activities, tool is executed for transformation with the application model. NWUML06, 12 June 2006
Case Study: Transformation Model TPG Component takes these two models and prepares transformation model with using • Add • Delete • Update • Unchanged labels. NWUML06, 12 June 2006
Case Study:Screen Shots NWUML06, 12 June 2006
Conclusions • We introduced a transformation tool that performs horizontal transformations for design pattern refactorings on design models. • Since XMI is not a query language, we could not generate complex definitions of the source model. • However, our approach in the implementation of the tool does not require to define transformation meta rules which simplifies the transformation implementation. NWUML06, 12 June 2006