UML Tutorial

Heinrich Hussmann Technische Universität Dresden Gianna Reggio Università di Genova

Heinrich Hussmann

Technische Universität Dresden

UML Tutorial

Outline
1. History of UML 2. Overview of notations in UML 3. Class Diagrams 4. Statechart Diagrams 5. Sequence Diagrams 6. Object Constraints: OCL

Heinrich Hussmann

Technische Universität Dresden

UML Tutorial

Semi-Formal Development Methods
1960 1970 1980 1990 2000 Object-oriented Modelling 2010

Combinations Function Modelling Data Modelling State Modelling Event Modelling

ERM SA/SD
Heinrich Hussmann

Statecharts SSADM OMT UML
UML Tutorial

SREM

Technische Universität Dresden

1995: Booch / Rumbaugh / Jacobson 1997: UML 1. (Booch) • UML is now further developed as an industry standard by the Object Management Group (OMG) Heinrich Hussmann Technische Universität Dresden UML Tutorial .Roots of UML OOD Booch OOSE Jacobson OMT Rumbaugh et al.1 (OMG adopted technology) • UML is a scond generation notation for diagram-based object-oriented modelling • UML was a development of the company Rational Corp.

) – OOSA (Odell/Martin) Heinrich Hussmann Technische Universität Dresden UML Tutorial ..Impact of UML • The following companies were involved among others in the OMG proposal for UML: – – – – – – – – – Rational Microsoft Hewlett-Packard Oracle IBM Unisys Platinum Softeam . • Well-known methods are reshaped in a UML-conformant way: – Fusion (Coleman et al..) – Catalysis (D'Souza et al.

) Heinrich Hussmann Technische Universität Dresden UML Tutorial .g. {disjoint}. <<uses>>. {subset}) – Example for an UML extension: » Real-time UML » based on ROOM (Selic et al.a process for UML • UML covers all levels of formality – informal requirements analysis (use cases) – semi-formal o-o modelling (static and dynamic models) – purely formal modelling and specification (OCL) • UML is extensible – Generic constructs: » stereotypes (e.g. {abstract}. <<derived>>) » element properties (e.Scope of UML • UML is a notation.g. {author="John"}) » constraints (e. not a method ! – UML can be applied in all phases of the development process – "Rational Unified Process" .

– Warmer/Kleppe: The Object Constraint Language . Addison-Wesley 1998.Information on UML • UML Resource Center: http://www.software.com/ • Information on OCL http://www. Addison-Wesley 1997.com/ad/ocl • Books: – Booch/Rumbaugh/Jacobson: Unified Modeling Langauge User Guide. Addison-Wesley 1998 (October !) Heinrich Hussmann Technische Universität Dresden UML Tutorial .ibm. Addison-Wesley 1998. (just published) – Rumbaugh/Booch/Jacobson: Unified Modeling Language Reference Guide. (to appear) – Fowler/Scott: UML Distilled.rational.Precise Modeling with UML.com/uml – UML Notation Guide – UML Semantics – Object Constraint Language Specification • OMG UML Revision Task Force http://uml.shl.

OMG Revision Schedule for UML • UML 1. 1999 Heinrich Hussmann Technische Universität Dresden UML Tutorial .4: – Minor revision – Projected completion: April 1.3: – Technical cleanup revision – Projected completion: November 1998 • UML 1.2: – Editorial (non-technical) cleanup revision – Completed: July 1998 – RFC Comment Deadline: October 1. 1998 • UML 1.

Class Diagrams 4. Overview of notations in UML 3. Object Constraints: OCL Heinrich Hussmann Technische Universität Dresden UML Tutorial . Sequence Diagrams 6. History of UML 2. Statechart Diagrams 5.Outline 1.

Diagram Types in UML • Static Structure Diagrams – Class Diagram – Object Diagram • Use Case Diagram • Interaction Diagrams – Sequence Diagram – Collaboration Diagram • Statechart Diagram • Activity Diagram • Implementation Diagrams – Component Diagram – Deployment Diagram Heinrich Hussmann Technische Universität Dresden UML Tutorial .

* employs CorpCustomer employeeNum department printLetter() Heinrich Hussmann Technische Universität Dresden UML Tutorial Course title 0.Static Structure Diagram: Class Diagram Party name address printLetter() Reservation dateBooked status cancel() Company turnover printLetter() 1 0..* date totalParticipants maxParticipants addReservation() cancel() Customer custNum printLetter() 0.* participant ...

" adress = "Dresden.Static Structure Diagram: Object Diagram CorpCustomer <<instance of>> x: CorpCustomer c: Company name = "XXY Ltd.." turnover = 105. ..23 employs name = "Joe Smith" adress = "" custNum = 9876 employeeNum = 1234 department = "A1" Heinrich Hussmann Technische Universität Dresden UML Tutorial .

Use Case Diagram Course Management introduce new course cancel course assign speakers produce catalog customer service make reservation cancel reservation programme maintenance Heinrich Hussmann Technische Universität Dresden UML Tutorial .

Interaction Diagram: Sequence Diagram :programme maintenance c: course addReservation() r1: Reservation addReservation() r2: Reservation cancel() cancel() cancel() printLetter() printLetter() x1: Customer x2: Customer Heinrich Hussmann Technische Universität Dresden UML Tutorial .

1: printLetter() 2.Interaction Diagram: Collaboration Diagram 3.2.1: create r2: Reservation {new} 3: cancel() 3.2: cancel() 0: create() :programme maintenance Heinrich Hussmann Technische Universität Dresden UML Tutorial .1: printLetter() x1: Customer 1: addReservation() r1: Reservation {new} 3.1: cancel() 1.1: create() c: course {new} 2: addReservation() x2: Customer 3.1.

cancelled [timeout] .Statechart Diagram Class "Course" / enter data update planned release course cancelled res. cancelled cancelled do/ cancel course cancelled full [timeout] / archive data over is_full: totalParticipants = maxParticipants timeout: today >= date Heinrich Hussmann Technische Universität Dresden UML Tutorial delete bookable [is full] new reservation res.

Activity Diagram process reservation check reservation check participant reject [ok] create reservation Heinrich Hussmann check availability [ok] reject Technische Universität Dresden UML Tutorial .

Implementation Diagram: Component Diagram User Interface Course Manager SQL Database Heinrich Hussmann Technische Universität Dresden UML Tutorial .

Imlementation Diagram: Deployment Diagram Client User Interface Server Client Application Course Manager SQL Database Heinrich Hussmann Technische Universität Dresden UML Tutorial .

Overview of notations in UML 3.Outline 1. History of UML 2. Object Constraints: OCL Heinrich Hussmann Technische Universität Dresden UML Tutorial . Class Diagrams 4. Statechart Diagrams 5. Sequence Diagrams 6.

History of UML 2. Overview of notations in UML 3. Class Diagrams 4. Object Constraints: OCL Heinrich Hussmann Technische Universität Dresden UML Tutorial .Outline 1. Statechart Diagrams 5. Sequence Diagrams 6.

Overview of notations in UML 3. History of UML 2. Class Diagrams 4.Outline 1. Statechart Diagrams 5. Sequence Diagrams 6. Object Constraints: OCL Heinrich Hussmann Technische Universität Dresden UML Tutorial .

Object Constraints: OCL Heinrich Hussmann Technische Universität Dresden UML Tutorial .Outline 1. Statechart Diagrams 5. Sequence Diagrams 6. History of UML 2. Overview of notations in UML 3. Class Diagrams 4.

IBM » OCL Definition: Jos Warmer (IBM).1 notation • Practicioners mostly ignore OCL ! – too complex ? – unnecessary ? Heinrich Hussmann Technische Universität Dresden UML Tutorial . submitted by IBM/ObjecTime – Formal definition of • • • • invariants pre.1 – History: » Syntropy (Cook/Daniels 1994) » IBEL (Integrated Business Engineering Language).L C OCL and UML • OCL = Object Constraint Language – OCL is officially part of UML 1.and postconditions guards navigation • OCL is used to define the "context conditions" for UML 1.

" OCL 1. September 1997 Heinrich Hussmann Technische Universität Dresden UML Tutorial . The disadvantage of formal languages is that they are useable only to persons with a strong mathematical background. OCL has been developed to fill this gap.OCL and Formal Methods "In order to write un-ambiguous constraints.1 Specification. but difficult for the average business or system modeler to use. so-called formal languages have been developed.

Basic OCL Concepts (1) • Invariant: <class name> <boolean expression> • Pre/postcondition.<attribute> <object expression>.: <class name>::<operation name>(<parameters>) pre: <boolean expression> post: <boolean expression> • self: – refers to an individual object of the described class – can be omitted where unambiguous • Properties: – Attribute: – Association: <object expression>.<role> <object expression>.<class name as role> Heinrich Hussmann Technische Universität Dresden UML Tutorial .

select. includes.. forall. including. Heinrich Hussmann Technische Universität Dresden UML Tutorial .. collect. . exists.Basic OCL Concepts (2) • Collection types (predefined): – Set – Bag – Seq • Navigation through association – results in a Set(Object) – or in a Seq(Object) if association is marked as {ordered} • Applying properties on collections: <collection expression> –> <collection property> • Predefined properties for collections: – size.

totalParticipants <= self..* participant Course title 0.Examples of Constraints (1) Reservation dateBooked status cancel() Customer custNum printLetter() 0.course.date >= self..dateBooked Heinrich Hussmann Technische Universität Dresden UML Tutorial .maxParticipants Reservation self.* date totalParticipants maxParticipants addReservation() cancel() Course self.

.* custNum dateRegistered participant printLetter() title 0.Examples of Constraints (2) Course Customer 0.course->forall(date >= self..* date totalParticipants maxParticipants addReservation() cancel() Course self.participant->size Customer self.totalParticipants = self.dateRegistered) Heinrich Hussmann Technische Universität Dresden UML Tutorial .

participant@pre->including(c)) and (self.totalParticipants = self.* custNum dateRegistered participant printLetter() title 0...Example of Pre/Postconditions Course Customer 0.maxParticipants) post: (self.totalParticipants@pre +1) Heinrich Hussmann Technische Universität Dresden UML Tutorial .* date totalParticipants maxParticipants addReservation() cancel() Course::addReservation(c: Customer) pre: not (self.participant = self.totalParticipants < self.participant->includes(c)) and (self.

– Some semantic issues are not yet tackled properly.oclType) Incomplete type conformance rules (subtypes of OclAny) Incomplete treatment of undefined values Ambiguities in navigation expressions Conversion from Bag or Set to Sequence causes inconsistencies Automatic flattening of collections (simple but may be too weak * * * * : More information follows. • Examples (partially based on [Gogolla. Heinrich Hussmann Technische Universität Dresden UML Tutorial .Problems with OCL • Basic problem: – Definition of OCL is very brief and informal. Richters 98]): – – – – – – Meta cycle in type hierarchy (OclType.

• Questions (from [Gogolla. Richters 98]): – Should not "undefined = undefined" yield True ? – Should not "if true the 1 else undefined endif" yield 1 ? – How is undefined related to the quantifiers ? Heinrich Hussmann Technische Universität Dresden UML Tutorial . the complete expression is undefined. – Exceptions: » True OR-ed with anything is True » False AND-ed with anything is False – These rules are valid irrespective of the order of the arguments.Rules for Undefined Values • OCL Rules: – Whenever a subexpression is undefined.

Conversion of Collections Course self. 2. 2. 1 } -> asSequence yields ?? • Assumption of order on types ? Which order for class types like Customer ? Heinrich Hussmann Technische Universität Dresden UML Tutorial . 3 } Set { 3. 2. Sequence { 1.g. in random order. 3 } -> asSequence yields e." Set { 1.participant->asSequence • OCL definition of 'asSequence': "A sequence that contains all the elements from the set.

dependency • OCL does not contain a way to specify the role to be used for this navigation. Heinrich Hussmann Technische Universität Dresden UML Tutorial .Navigation Ambiguities prequisite Dependency Course title date totalParticipants maxParticipants follow-up addReservation() cancel() examGrade Course self.

Tools for OCL • IBM OCL Parser. public domain incl.3 – written in Java (JavaCC). sources – syntactical checking and partial (!) type checking Heinrich Hussmann Technische Universität Dresden UML Tutorial . Version 0.

Sign up to vote on this title
UsefulNot useful