Representing Patterns
Representing Patterns
in UML
in UML
Andy Bulka
Andy Bulka
www.atug.com/andypatterns
www.atug.com/andypatterns
Technical Director
Technical Director
Austhink Software
Austhink Software
www.austhink.com
www.austhink.com
The competitors
The competitors
n
n
IBM Rational has “pattern instances” on your UML
IBM Rational has “pattern instances” on your UML
diagram and you can re-apply a pattern and it enforces
diagram and you can re-apply a pattern and it enforces
it.
it.
n
n
ObjectIf has some pretty cool design pattern support
ObjectIf has some pretty cool design pattern support
and uses roles and colors to indicate patterns.
and uses roles and colors to indicate patterns.
n
n
EA (Enterprise Architect has design pattern support,
EA (Enterprise Architect has design pattern support,
though the merge feature is a bit buggy at the moment).
though the merge feature is a bit buggy at the moment).
n
n
StarUML is free, and has a configurable patterns system.
StarUML is free, and has a configurable patterns system.
n
n
ModelMaker, classic pattern “enforcer”, with code
ModelMaker, classic pattern “enforcer”, with code
regions etc. Now a bit old, has only a limited number of
regions etc. Now a bit old, has only a limited number of
patterns – to be improved in the next few months.
patterns – to be improved in the next few months.
IBM Rational - pattern instance itself
IBM Rational - pattern instance itself
is a first class modeling element
is a first class modeling element
n
n
The pattern instance itself is a first class
The pattern instance itself is a first class
modeling element, and appears in the model and
modeling element, and appears in the model and
can be placed in a diagram and has relationships
can be placed in a diagram and has relationships
to other model elements that bind its parameters
to other model elements that bind its parameters
to actual model elements.
to actual model elements.
n
n
Having pattern instances in a model help
Having pattern instances in a model help
designers understand which patterns have been
designers understand which patterns have been
applied (since many might have been).
applied (since many might have been).
Applying Patterns to the workspace
Applying Patterns to the workspace
n
n
Most have a clear, standard way of applying
Most have a clear, standard way of applying
patterns i.e. you specify if you want to create a
patterns i.e. you specify if you want to create a
new
new
class or
class or
merge
merge
a role with an existing class.
a role with an existing class.
UML diagram previews in the pattern wizards,
UML diagram previews in the pattern wizards,
too. And most tools also have a way of
too. And most tools also have a way of
representing the pattern on the diagram e.g.
representing the pattern on the diagram e.g.
collaboration lines or class stereotypes or
collaboration lines or class stereotypes or
association lines with role labels.
association lines with role labels.
n
n
Rational has
Rational has
drag drop
drag drop
wiring – nice.
wiring – nice.
Pattern is comprised of
Pattern is comprised of
n
n
Classes (one or more)
Classes (one or more)
n
n
Attributes
Attributes
n
n
Methods
Methods
n
n
Code fragments within methods (aspects?)
Code fragments within methods (aspects?)
n
n
Meta information tying all the above together
Meta information tying all the above together
Ways of Representing the Grouping
Ways of Representing the Grouping
of classes
of classes
n
n
Shading areas behind classes, grouping them.
Shading areas behind classes, grouping them.
(vlissedes)
(vlissedes)
n
n
Shaded areas can overlap to indicate classes
Shaded areas can overlap to indicate classes
performing different roles within different
performing different roles within different
patterns i.e.
patterns i.e.
a class can be part of more than
a class can be part of more than
one pattern
one pattern
n
n
Sticky notes near classes
Sticky notes near classes
n
n
Role labels on properties (ObjectIf)
Role labels on properties (ObjectIf)
Ways of Representing the Grouping
Ways of Representing the Grouping
of classes
of classes
n
n
Collaboration objects (Rational)
Collaboration objects (Rational)
n
n
Text Lists in a panel (ModelMaker)
Text Lists in a panel (ModelMaker)
n
n
Package diagrams with interfaces to the pattern
Package diagrams with interfaces to the pattern
exposed.
exposed.
The Software Tools
The Software Tools
n
n
Demo
Demo
Rational (by IBM and the inventors of UML)
ObjectIF – excellent pattern support. Gui overly redundant
and confusing in some places, but community edition is free.
StarUML – free, poor code generation but has
customisation facility in some javascript like language.
Documentation poor.
Modelmaker – pattern support lags behind – missing
complete set of GOF patterns. Check it again in 2007.
Enterprise Architect – pattern blending support poor, but
good UML tool with good reverse engeneering and layout.
Interface very messy though. Affordable.
StarUML
StarUML
n
n
Free
Free
tool
tool
StarUML
StarUML
n
n
R.click and select Apply Pattern
R.click and select Apply Pattern
StarUML
StarUML
n
n
Select the class you want to apply the singleton
Select the class you want to apply the singleton
to. If you don’t select, a new class will be
to. If you don’t select, a new class will be
created.
created.
StarUML
StarUML
n
n
Voila!
Voila!
StarUML
StarUML
n
n
To view the generated code, r.click
To view the generated code, r.click
StarUML
StarUML
n
n
Output not very correct in this case – missing
Output not very correct in this case – missing
private constructor.
private constructor.
Other demos
Other demos
I demo’d all the 5 tools on the night, and
there is a video of me doing them all.
At the moment the only video released is
on my website is the Rational UML tool
portion of the demo – see www.andypatterns.com
Final word
Final word
n
n
Also see
Also see
www.andypatterns.com
www.andypatterns.com
for another more academic
for another more academic
paper on design pattern automation – pros and cons
paper on design pattern automation – pros and cons
and asking is it a good idea in the first place.
and asking is it a good idea in the first place.