University of Utah SoC CS 6961 - Lecture 15 1
Inside UML
CS6961 – Lecture 15
Nathan Dykman
University of Utah SoC CS 6961 - Lecture 15 2
Administration
• Grading Started– Please get in HW4, if you haven’t already.
• Okay, topics of discussion coming up:– QA, Testing and Release Engineering
• Metrics
– Reverse Engineering of Complex Systems• Real World Examples
– MDA and SOA – Refactoring– Did I miss anything?
University of Utah SoC CS 6961 - Lecture 15 3
Today’s Lecture
• Today: I’m going to give you a peek behind the UML curtain– Give you an idea of how UML is put together
University of Utah SoC CS 6961 - Lecture 15 4
UML Worries
• The main question people ask after dealing with UML after a while is: “Why it is so complicated?”
• I’m sure you have some of these kinds of questions– Examples?
• This lecture hopes to explain some of the complexity
University of Utah SoC CS 6961 - Lecture 15 5
UML: Incompleteness
• The major part that throws people is that UML allows incomplete models– But, in some cases, complete information
must be provided. (Example?)– Some view this as a major shortcoming
• It is a shortcoming, but not as big as it seems.
– But is incompleteness really bad?• Think about regular code files here.
University of Utah SoC CS 6961 - Lecture 15 6
UML: Incompleteness
• The hard part about UML is that you can’t just save a model in “any old state”– There is work on this, actually.
• But, most tools disallow some kinds of invalid models to be created– But, not all. A model can be semantically
incorrect, but still created in a tool. • Why?
University of Utah SoC CS 6961 - Lecture 15 7
UML: Ambiguity
• One constant annoyance in UML is that if something isn’t there, doesn’t mean it isn’t somewhere.– What’s worse, in some cases, missing
information “assumes” default values, in others, it is merely “unspecified”
• The rule is to assume the least possible– This works in most cases, but not all.
University of Utah SoC CS 6961 - Lecture 15 8
Class Example
Testing
+ anAttribute+ anAttribute : int
+ operation ( )+ operation ( )+ operation ( )
Testing
+ anAttribute+ anAttribute : int
+ operation ( )+ operation ( [in] foo : int )+ operation ( [in] foo : int , [in] bar : string ) : int
Testing
+ anAttribute+ anAttribute : int+ moreAttributes
+ operation ( )+ operation ( [in] foo : int )+ operation ( [in] foo : int , [in] bar : string ) : int
University of Utah SoC CS 6961 - Lecture 15 9
UML: Ambiguity
• This problem comes from a subtle part of UML. Diagrams aren’t models. – A diagram is merely just a view on a model. A
model is complete.– Why is a diagram just a view on a model?
• Programming languages don’t do this, right?
– So, we can view the previous example as three different views on a single class.
• In the model, there is one class
University of Utah SoC CS 6961 - Lecture 15 10
UML: Ambiguity
• The problem is made a more difficult in that there is diagrams are the only UML syntax that tools provide– This made worse by the standard XML format
of UML (XMI)• To my mind: XMI is pretty broken• The latest versions may help address this
– But there are too many versions to deal with in the first place.
University of Utah SoC CS 6961 - Lecture 15 11
Modeling Future
• In the future, it is likely UML and other modeling languages will require better textual formats as well as visual syntax– There is already a standard “human-usable”
format that looks more like code• Sadly, very little support for it.
– Some tools provide a data-grid like editors.– But, we need things like XML, Relational
Schemas, etc.
University of Utah SoC CS 6961 - Lecture 15 12
UML: Complexity
• Another major complaint about UML, is well, there is sure a lot of it– I agree with this. UML could lose some bulk– Main problem is nobody can really agree on
what to cut, and everybody has something they want to add
– UML in the middle of the “second-system” effect
• Hopefully, feature set will shake out with more use
University of Utah SoC CS 6961 - Lecture 15 13
UML: Complexity
• Of course, just because it’s there, doesn’t mean you have to use it– In many cases, a large part of UML is for
specialized audiences• Some talk of making a xUML language for these
advanced bits
– Strive to use the smallest subset that does the job
• But don’t reinvent the wheel either.
University of Utah SoC CS 6961 - Lecture 15 14
UML: Complexity
• As model-driven development moves forward, hopefully the complexity will start to pay off– More complex code generation– Direct model execution or interpretation– Better integration with languages
• For now, certain domains benefit the most– Telecommunications, embedded real-time are
the best examples.
University of Utah SoC CS 6961 - Lecture 15 15
Behind The Curtain
• One common benchmark on computer languages is “can it describe itself”– Some languages make this dead easy
(Scheme)– Others, more complex (Perl Compiler in Perl)– This “benchmark” has major drawbacks
• “Little languages” (Domain specific programming languages) suffer in this area.
University of Utah SoC CS 6961 - Lecture 15 16
The UML Metamodel
• UML is used to describe UML.– Well, in reality, it’s more complex than that– Only a small subset of UML is used currently
• Restricted class diagrams• Object Constraint Language (which has a
metamodel as well)
– Metamodeling still an area of research and development
• My PhD work lives in this space, for example• EMF from IBM, Corona from Microsoft
University of Utah SoC CS 6961 - Lecture 15 17
Metamodel Example
MultiplicityElement
Element
Namespace
TypedElement(from Basic)
MultiplicityElement(from Multiplicities)
Classi fier(from Super)
RedefinableElement(from Redefinitions)
Feature(from Classifiers)
StructuralFeature
StructuralFeature(from Changeabilities)
TypedElement
RedefinableElement
*
/redefinedElement
* {union}
Feature
Classi fier
*
/redefinitionContext
* {union}
*1..*
/feature
*{union,subsets member}
/featuringClassifier
1..* {union}
*
+general
*
TypedElement Type
0..1
type
0..1
Type(from Basic)
Type(from TypedElements)
TypedElement(from TypedElements)
NamedElement
NamedElement NamedElement
Type
University of Utah SoC CS 6961 - Lecture 15 18
Metamodel Example
• As you can see, the metamodel really isn’t fit for normal consumption– Certain parts of the metamodel are much
more complex than this– You have to learn how to “read the runes”
• However, the UML metamodel is the core what is legal and illegal UML– What can relate to what, what contains what,
the data, etc.
University of Utah SoC CS 6961 - Lecture 15 19
Metamodel Example 2
[0..1]
StructuralFeatureClassi fier
AggregationKind
nonesharedcomposite
<<enumeration>>
Relationship
[0..1]
Classi fier
Operation
Classi fier
ValueSpecification
Class
0..1 *
+class
0..1 {subsets namespace,subsets redefinitionContext}
+nestedClassifier
*{ordered, subsets ownedMember}
*
+/superClass
*{redefines general}
0..1 *
+class
0..1 {subsets redefinitionContext,subsets namespace,
subsets featuringClassifier}
+ownedOperation
*{ordered,subsets feature,
subsets ownedMember}
Property
isDerived : Boolean = falseisReadOnly : Boolean = falseisDerivedUnion : Boolean = false/ defaul t : Stringaggregation : AggregationKind = none/ isComposi te : Boolean
*
+redefinedProperty
*{subsets redefinedElement}
0..1
+/opposite
0..1
*
+subsettedProperty
*
0..1 *
+classifier
0..1 {subsets redefinitionContext}
+/attribute
*{union,subsets feature}
0..1 0..1
+owningProperty
0..1 {subsets owner}
+defaul tValue
0..1{subsets ownedElement}
0..1 *
+class
0..1 {subsets classifier,subsets namespace,
subsets featuringClassifier}
+ownedAttribute
*{ordered,subsets attribute,
subsets ownedMember}
Association
isDerived : Boolean = false
0..1*
+owningAssociation
0..1{subsets association,subsets namespace,
subsets featuringClassifier}
+ownedEnd
* {ordered,subsets memberEnd,
subsets feature,subsets ownedMember}
0..12..*
+association
0..1
+memberEnd
2..* {ordered,subsets member}
Type
1..*
+/endType
1..*
This is the basic UML class.
University of Utah SoC CS 6961 - Lecture 15 20
Metamodeling
• After seeing these models, I hope you feel a bit better about your class models– I mean, I could make you do this kind of thing.
• Really. I did it, so you can too… Right?
• Of course, these models aren’t example of “real-world models”– They have a very specific purpose.– “Real world” models much closer to code.
University of Utah SoC CS 6961 - Lecture 15 21
UML: Extensibility
• UML was built to be extended.
• For most people, it is enough to know that there is a thing called a “stereotype”– An a collection of stereotypes is a “profile”
• This should work for you as well– But UML can be extended in much more
powerful ways (tool support missing)
University of Utah SoC CS 6961 - Lecture 15 22
UML, DSMLs, Extensiblity
• Microsoft’s new initiative focuses on “Domain Specific Modeling Languages”– Part of Visual Studio 2005 modeling tools is a
toolkit for building new modeling languages– Codenamed Corona, now just part of VS 2005– Keep a eye on this (It’s really cool)– UML, Eclipse/Java community will get shaken
up by this, I think
University of Utah SoC CS 6961 - Lecture 15 23
UML Deconstructed
• Trust me when I say we can have a class just on the future of modeling, DSMLs, advanced model development…– Well, I hope so, because…
• It’s a planned seminar next semester (CS 7940-00x, TBA)– Prof. Kessler likely to be the official instructor
• I’ll be lucky to TA a 1000 level class after this…
University of Utah SoC CS 6961 - Lecture 15 24
UML Seminar
• Open to all that took this class– This includes seniors as well
• If you’ve never taken a seminar, I encourage it highly!
• Much different than this class– One credit hour: You must present a paper to
the class (Suggested papers will be available)– Three credit hours: Independent project
subject to my approval (limited to 2 students)
University of Utah SoC CS 6961 - Lecture 15 25
Coming Up
• An assortment of topics of interest to you– Or, pick your instructors brain.
• Again, if you have any other suggestions, let me know.– Also, look for HW5 this week!