Domain-Specific Profiles for Your UML Tool
description
Transcript of Domain-Specific Profiles for Your UML Tool
Dr. Darius Silingas | No Magic, Inc.
Domain-Specific Profilesfor Your UML ToolBuilding DSL Environments with MagicDraw UML
Dr. Darius Silingas | No Magic, Inc.
Contents
• UML Extension Mechanisms• MagicDraw DSL Customization Engine• Workflow for Creating DSL Environment• A Case Study: DSL for Modeling Organization
Structure
Dr. Darius Silingas | No Magic, Inc.
UML (Unified Modeling Language)
• De facto standard software modeling language– Standardized for 10 years already– Very popular but still not used by everyone– UML extension mechanisms are not anything new!– UML tools are starting to develop features for DSL
Dr. Darius Silingas | No Magic, Inc.
UML Universal Modeling Language
Dr. Darius Silingas | No Magic, Inc.
OMG 4 Layer Metamodel
MOF
UML metamodel
User model (UML)
Real world
corresponds to
corresponds to
corresponds to
UML diagramsbased on
is modeled using
M3
M2
M1
M0
Dr. Darius Silingas | No Magic, Inc.
UML Extension Elements
• Profile is a reusable set of UML extensions• Stereotype extends semantics of standard UML
metaclass(es) and may also define additional properties and custom appearance icon– Tag Definition specifies additional property that is not
available in the extended metaclass(es)
• Constraint is a rule for domain-specific model correctness or completeness
• Also: Data Type, Enumeration, …
Dr. Darius Silingas | No Magic, Inc.
Stereotype Definition and Application
<<Employee>>Darius Silingas
{e-mail = "[email protected]" , first name = "Darius" , last name = "Šilingas" , phone = "+37068612748" }
<<Employee>>Darius Silingas
<<Employee>>
e-mail = "[email protected]"first name = "Darius"last name = "Šilingas"phone = "+37068612748"
<<metaclass>>Class
<<stereotype>>Employee
first name : Stringlast name : Stringe-mail : Stringphone : String
Dr. Darius Silingas | No Magic, Inc.
Contents
• UML Extension Mechanisms• MagicDraw DSL Customization Engine• Workflow for Creating DSL Environment• A Case Study: DSL for Modeling Organization
Structure
Dr. Darius Silingas | No Magic, Inc.
Problems of UML Profiles
• UML modeling environment is too complex
• Applying stereotype doesn’t hide the UML properties, terminology, etc.
• Difficult to restrict usage of standard UML elements and ensure model correctness
Dr. Darius Silingas | No Magic, Inc.
MagicDraw UML DSL Engine
Custom Diagram Wizard– Custom diagram for DSL profile with custom toolbar
elements, symbol styles, smart manipulators
DSL Customization– DSL stereotype appearance as first-class element– Custom specification editors– Custom context menus– Additional rules for model initialization and restrictions
Enhanced UML Profiling– Tag grouping, hiding stereotypes and tags,
customizing paths, etc.
Dr. Darius Silingas | No Magic, Inc.
Contents
• UML Extension Mechanisms• MagicDraw DSL Customization Engine• Workflow for Creating DSL Environment• A Case Study: DSL for Modeling Organization
Structure
Dr. Darius Silingas | No Magic, Inc.
Workflow for Creating DSL Environment
1. Define DSL metamodel
2. Map DSL metamodel to UML profile
3. Create DSL sample
4. Define customizations for stereotypes
5. Define validation rules
6. Create custom DSL diagram
7. Test the created DSL environment
Dr. Darius Silingas | No Magic, Inc.
Contents
• UML Extension Mechanisms• MagicDraw DSL Customization Engine• Workflow for Creating DSL Environment• A Case Study: DSL for Modeling Organization
Structure
Dr. Darius Silingas | No Magic, Inc.
1. Define DSL Metamodel
ProjectRole
Organization
OrganizationRole
Project
OrganizationUnit
Skill
Role
Employee
has
1..*
0..*
plays0..*0..*
work on
0..*
1..*
defines1
1..*has 10..*
contains
1..*
1
contains
0..*
1
requires
1..*
0..*
specifies
1..*
1supervises
0..*0..1
works in
1
1..*
Dr. Darius Silingas | No Magic, Inc.
2. Map DSL Metamodel to UML Profile
<<stereotype>>Organization
[Package]
id : IntegerVAT code : Integertype : OrgType
<<stereotype>>Project
[Package]
start : dateend : datedescription : String
<<stereotype>>OrganizationRole
[Actor]
<<stereotype>>ProjectRole
[Actor]
<<stereotype>>Employee
[Class]
first name : Stringlast name : Stringe-mail : Stringphone : String
<<stereotype>>Supervise
[Dependency]
start : dateend : date
<<stereotype>>OrganizationUnit
[Package]
title : Stringaddress : Stringdescription : String
<<stereotype>>Skill
[Class]
description : String
<<stereotype>>RoleAssignment
[Dependency]
start : dateend : dateworkload : float
<<stereotype>>Role
[Actor]
instructions : String
department1
-requiredSkills
1..*
team
1..*
prerequisites
0..*
clients
1..*
skills
1..*
project
1suppliers
1..*
manager 1
Dr. Darius Silingas | No Magic, Inc.
3. Create DSL Sample
• Should represent all major aspects of DSL!
<<OrganizationUnit>>
Training
<<Employee>>Darius Šilingas
<<Employee>>
e-mail = "[email protected]"phone = "+37068612748"skills = English UML 2 MDA DSL
<<OrganizationRole>>Principal Trainer
<<Employee>>Ruslnas Vitiutinas
<<Skill>>openArchitectureWare
<<Skill>>Java Programming
<<Skill>>DSL
<<Skill>>English
<<Skill>>MDA
<<Skill>>UML 2
<<Supervise>><<RoleAssignment>>
Dr. Darius Silingas | No Magic, Inc.
4. Create Customizations for Stereotypes
• Customizations are model elements, part of profile!
<<Customization>>EmployeeCustomization
<<Customization>>
allowedRelationships = RoleAssignment SupervisecustomizationTarget = EmployeehideMetatype = truepossibleOwners = OrganizationUnit
Dr. Darius Silingas | No Magic, Inc.
5. Define Validation Rules
• Employees can be placed only in organization units
• Validation rules are constraints, part of profile!• Possibility to validate the user model against the rule!!
<<stereotype>>Employee
{owner.oclIsKindOf(OrganizationUnit)}
first name : Stringlast name : Stringe-mail : Stringphone : String
Dr. Darius Silingas | No Magic, Inc.
6. Create Custom DSL Diagram
• Custom diagrams can be exported to XML descriptors and imported in other machines!
Dr. Darius Silingas | No Magic, Inc.
7. Test the Created DSL Environment
• Demonstration in MagicDraw UML
Dr. Darius Silingas | No Magic, Inc.
Enabling the Full Power of DSL
Create DSL-specific transformations– Model reports– DSL-specific patterns– Model 2 Model transformations– Model 2 Code transformations
Create guidance for DSL modeling– Project templates– Samples and tutorials– Modeling wizards– Reusable model libraries
Dr. Darius Silingas | No Magic, Inc.
Why UML Profiles?
• Reuse of modeling environment features– Single modeling environment for different roles
• Possibility to use the extensions in standard UML diagrams– e.g., assign project role to activity swimlane
• Standardized model data storage and ability to interchange data between tools– MDA tools can be used for code generation
Dr. Darius Silingas | No Magic, Inc.
References
• OMG. Unified Modeling Language: Superstructure– Formal Specification, version 2.1.2, 2007
• Bran Selic. A Systematic Approach to Domain-Specific Language Design Using UML
• Darius Silingas et. al. A Method for Creating Domain-Specific Modeling Environment Based on UML Profiles– Coming out this summer, check www.magicdraw.com
Dr. Darius Silingas | No Magic, Inc.
Questions
???Let’s Keep in Touch!
– E-mail: [email protected]– Skype: darius.silingas