Escolar Documentos
Profissional Documentos
Cultura Documentos
Understanding
• about conceptual modeling issues.
Advanced UML Concepts • addressing the domain analysis view point.
• restricted to state modeling (class models).
Gerd Wagner
http://GerdWagner.rezearch.info
• Role Names
• Generalization 8 3 2 : P a tie n t 1 5 6 1 : P a tie n t
• (Integrity) Constraints
9 4 5 : P a tie n t
7 1 2 : P a t ie n t 8 6 3 : P a t ie n t
Gerd Wagner: Understanding Advanced UML Concepts 5 Gerd Wagner: Understanding Advanced UML Concepts 6
1
The Association has between
Patient and Consultation Associations with Role Names
“An instance of an Association is a Link, which is a tuple of
Instances drawn from the corresponding Classifiers.”
Patient
has
Consultation
W ife
has
Person isMarriedW ith
832 : Patient 19940221032 : Consultation
has
872 : Patient 19990831074 : Consultation
has
Husband
1561 : Patient 20010413055 : Consultation
Gerd Wagner: Understanding Advanced UML Concepts 7 Gerd Wagner: Understanding Advanced UML Concepts 8
2
Consider the association hasAppointmentWith: Consider the association hasAppointmentWith:
hasAppointmentWith hasAppointmentWith
Patient Doctor Patient Doctor
* * * *
Problem: How to include the date and time of Problem: How to include the date and time of
an appointment? an appointment?
hasAppointmentWith Doctor
Patient Date
* * Time
Is this a solution?
Gerd Wagner: Understanding Advanced UML Concepts 13 Gerd Wagner: Understanding Advanced UML Concepts 14
Gerd Wagner: Understanding Advanced UML Concepts 15 Gerd Wagner: Understanding Advanced UML Concepts 16
3
Association Class
An association class
versus Object Class
• … is an association that is also a class. Appointment
Date
It not only connects a set of classes but Time
{unique}
Gerd Wagner: Understanding Advanced UML Concepts 19 Gerd Wagner: Understanding Advanced UML Concepts 20
Questions
• are used in the definition of UML itself • allow to specify user-defined meta-
for defining standard model elements attributes (tagged values) for a model
that are not considered complex enough element
to be defined directly as UML • should be defined in conjunction with a
metaclasses stereotype since that allows them to be
• A coherent set of Tags, Constraints and used in a more disciplined manner
Stereotypes, defined for specific • Example of a predefined tag: derived
purposes, constitutes a UML profile. (refers to ModelElement)
Gerd Wagner: Understanding Advanced UML Concepts 23 Gerd Wagner: Understanding Advanced UML Concepts 24
4
Constraints
Examples of Tag Definitions • allow to specify semantics/usage for a model
element
Tag Base Class Type Multi- • may be expressed by means of (predefined or
or plicity user-defined) keywords, or in a
– designated constraint language (such as OCL)
Stereotype
– a programming language
aliasNames ModelElement UML::Datatypes: * – mathematical notation, or
:String – natural language
• can be enforced by a tool, if it “understands” the
derived ModelElement UML::Datatypes: 1 syntax and semantics of the constraint language.
:Boolean • Example of a predefined constraint keyword:
disjoint (refers to Generalization)
Gerd Wagner: Understanding Advanced UML Concepts 25 Gerd Wagner: Understanding Advanced UML Concepts 26
Gerd Wagner: Understanding Advanced UML Concepts 27 Gerd Wagner: Understanding Advanced UML Concepts 28
5
Powertypes Example: ProductType
Supplier
• are special classes, designated with the Enterprise
1 1
ProductIndividual
stereotype !powertype"
*
Customer
whose instances are classes in the Organization
1
«powertype»
model.” ProductType
{disjoint, complete}
LegalEntity
• In UML 2: “a class whose instances are
subclasses of another class”. Person
Gerd Wagner: Understanding Advanced UML Concepts 31 Gerd Wagner: Understanding Advanced UML Concepts 32
Questions
6
Aggregation Composition
7
Inseparable Parts may be Shareable An aggregation relationship is
Lecture RegularCourse
1..* 1 • anti-symmetric: when an object o1 is
{inseparable = true}
*
part of an aggregate object o2, then o2
StudiumGeneraleCourse cannot be part of o1
*
• transitive: when an object o1 is part of
Although Lecture is an inseparable part of RegularCourse,
an aggregate object o2, and o2 is part
it is shareable.
of another aggregate object o3, then o1
is also part of o3.
Gerd Wagner: Understanding Advanced UML Concepts 43 Gerd Wagner: Understanding Advanced UML Concepts 44
• All expressions in OCL have a type and • A rental car is available, if it is not
evaluate to a value from that type when assigned to a rental contract, and it
applied to a specific context. does not require service.
• In OCL, a constraint is called an • A driver of a rental car must be at least
invariant. 25 years old.
• In addition to invariants, OCL allows to • The age of a person is computed as the
define preconditions and postconditions difference between the current year and
for operations. the person’s birth year.
Gerd Wagner: Understanding Advanced UML Concepts 47 Gerd Wagner: Understanding Advanced UML Concepts 48
8
Expressing Business Rules with
Bibliography
OCL Invariants
0..1 /isDrivenBy 0..1
• James Martin and James Odell. Object-
Oriented Methods: A Foundation (UML
RentalCar
isAssignedTo Driver Person Edition), Prentice-Hall, 1998. This book
RentalCarID : String
requiresService : Boolean
RentalContract Name : String
DateOfBirth : Date
presents the fundamental concepts
1 0..1 * 1
/isAvailable : Boolean /Age : Integer underlying the object-oriented approach in a
clear, concise manner using the Unified
«invariant»
Modeling Language (UML). It also introduces
«invariant»
{ RentalContract->isEmpty
and not requiresService
{Driver.Age>24}
«invariant»
{Age = Year() - Year(DateOfBirth)}
more advanced structures—including
implies isAvailable} constraints, business rules, meta-modeling,
power types, and dynamic and multiple
classification.
Gerd Wagner: Understanding Advanced UML Concepts 49 Gerd Wagner: Understanding Advanced UML Concepts 50