Dynamic Languages World

advertisement
Dr. Darius Silingas | No Magic, Inc.
Domain-Specific Profiles
for Your UML Tool
Building DSL Environments with MagicDraw UML
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
M3
MOF
corresponds to
M2
UML metamodel
UML diagrams
based on
corresponds to
M1
is modeled using
User model (UML)
corresponds to
M0
Real world
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
<<metaclass>>
Class
<<Employee>>
Darius Silingas
<<Employee>>
e-mail = "dariuss@nomagic.com"
first name = "Darius"
last name = "Šilingas"
phone = "+37068612748"
<<stereotype>>
Employee
first name : String
last name : String
e-mail : String
phone : String
<<Employee>>
Darius Silingas
{e-mail = "dariuss@nomagic.com" ,
first name = "Darius" ,
last name = "Šilingas" ,
phone = "+37068612748" }
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.
2.
3.
4.
5.
6.
7.
Define DSL metamodel
Map DSL metamodel to UML profile
Create DSL sample
Define customizations for stereotypes
Define validation rules
Create custom DSL diagram
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
has
1..*
Skill
Organization
1
1..*
contains
requires
0..*
1..*
OrganizationUnit
1
1
contains
0..*
1
0..*
Role
defines
works in
1..*
Employee
0..*
has
1
1..*
OrganizationRole
ProjectRole
0..*
0..1
1..* 0..*
0..*
1..*
plays
specifies
supervises
1
Project
work on
0..*
Dr. Darius Silingas | No Magic, Inc.
2. Map DSL Metamodel to UML Profile
<
<
s
t
e
r
e
o
t
y
p
e
>
>
<
<
s
t
e
r
e
o
t
y
p
e
>
>
<
-
Employee
[Class]
s
k
i
1
first name : String
last name : String
e-mail : String
phone : String
m
a
n
<
a
<
g
s
e
t
r
e
r
.
l
.
l
Skill
[Class]
s
e
a
1
.
1
e
.
q
.
u
i
r
e
d
S
k
i
l
l
<
s
t
e
r
e
o
t
y
p
e
>
>
s
Role
[Actor]
*
*
d
t
r
e
s
c
r
i
p
t
i
o
n
:
S
t
r
i
n
p
r
0
.
e
r
e
q
u
i
s
i
t
e
s
g
i
n
s
t
r
u
c
t
i
o
n
s
:
S
t
r
i
n
g
m
.
.
*
*
1
e
o
t
y
p
e
>
<<stereotype>>
Project
[Package]
>
OrganizationUnit
[Package]
s
u
p
p
l
i
e
r
s
<
p
r
o
j
e
c
<
s
t
e
r
e
o
t
y
p
e
>
>
<
ProjectRole
[Actor]
t
<
s
t
e
r
e
o
t
y
p
e
>
>
OrganizationRole
[Actor]
1
t
i
t
l
e
:
S
t
r
i
n
g
s
1
a
d
d
d
e
s
r
e
s
s
:
S
t
r
i
n
r
i
p
t
i
o
n
:
S
.
t
r
i
n
l
i
e
n
t
g
1
1
d
e
p
a
r
t
m
.
e
t
a
r
t
:
d
a
t
e
*
g
c
c
.
.
e
n
d
d
e
s
:
d
a
t
e
s
c
r
i
p
t
i
o
n
:
S
t
r
i
n
g
*
n
t
<<stereotype>>
Organization
[Package]
id : Integer
VAT code : Integer
type : OrgType
<<stereotype>>
Supervise
[Dependency]
s
e
t
a
n
r
d
t
:
:
d
d
a
a
t
t
e
e
<
<
s
t
e
r
e
o
t
y
p
e
>
>
RoleAssignment
[Dependency]
s
e
w
t
a
n
r
t
d
o
:
d
:
r
k
a
d
l
o
t
a
a
t
d
e
e
:
f
l
o
a
t
Dr. Darius Silingas | No Magic, Inc.
3. Create DSL Sample
<<OrganizationUnit>>
Training
<<Employee>>
Darius Šilingas
<
<
R
o
l
e
A
s
s
i
g
n
m
e
<<OrganizationRole>>
Principal Trainer
n
t
>
<<Employee>>
>
e-mail = "dariuss@nomagic.com"
phone = "+37068612748"
skills =
E
U
n
g
M
D
<<Skill>>
English
<<Skill>>
Java Programming
l
M
L
D
S
i
s
<<Supervise>>
<<Employee>>
Ruslnas Vitiutinas
h
2
A
L
<<Skill>>
UML 2
<<Skill>>
MDA
<<Skill>>
DSL
<<Skill>>
openArchitectureWare
• Should represent all major aspects of DSL!
Dr. Darius Silingas | No Magic, Inc.
4. Create Customizations for Stereotypes
<<Customization>>
EmployeeCustomization
<<Customization>>
allowedRelationships =
R
o
S
c
u
s
h
i
p
o
t
d
o
e
s
s
u
m
M
i
e
i
b
l
l
e
A
p
z
t
e
e
r
a
a
t
t
O
s
y
i
v
i
o
n
p
w
s
s
g
n
a
=
e
m
e
n
t
e
T
e
n
i
r
r
t
s
g
r
=
e
u
t
=
E
m
p
l
o
y
e
e
e
O
r
g
a
n
i
z
a
t
i
o
n
U
n
i
t
• Customizations are model elements, part of profile!
Dr. Darius Silingas | No Magic, Inc.
5. Define Validation Rules
• Employees can be placed only in organization units
<<stereotype>>
Employee
{owner.oclIsKindOf(OrganizationUnit)}
first name : String
last name : String
e-mail : String
phone : String
• Validation rules are constraints, part of profile!
• Possibility to validate the user model against the rule!!
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 DomainSpecific 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: darius.silingas@nomagic.com
– Skype: darius.silingas
Dr. Darius Silingas | No Magic, Inc.
Download