Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop:...

60
Introduction to the Unified Modeling Language (UML) Delos NoE , Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford Internet Institute
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    217
  • download

    1

Transcript of Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop:...

Page 1: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

Introduction to the Unified Modeling Language (UML)

Delos NoE , Preservation Cluster

Workshop: Persistency in Digital Libraries

13. February 2006, Oxford Internet Institute

Page 2: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

1

„Nobody, not even the creators of UML, understand or use all of it. Most people use a small subset of the UML and work with it.“

„UML is so complex that the standard is often open to multiple interpretations.“

„People do adopt conventions both in the industry widely and within a particular project.“

(Martin Fowler, „UML Destilled“)

Introductory Quotations

Page 3: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

2

UML – what is it good for?

• Visualisation: graphical representation of structures and processes

• Specification: Building models that are precise, unambigous and complete

• Construction: Converting UML-models into programming code

• Documentation: Illustration and mapping of systems architecture, requirements analysis, managing different versions of systems or parts of it

Page 4: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

3

Basic concepts: What is an object?

An object can be

A thing, e.g., car, office, book

A person, e.g., librarian, director

A term, e.g., programming language, disease

Synonymously, it is also called instance.

Page 5: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

4

An object can be featured

by

• State• Behaviour• Identity

Page 6: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

5

UML Representation of an object

elisabeth elisabeth:Cow :Cow

object:Class

Page 7: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

6

The state of an object includes its attributes and its relationships to other objects.

An attribute can have a value.

:Cow

Colour = brownAge

:Cow

Colour : stringAge : integer = 5

Object:Class

Attribute : type= value

Object: State

Page 8: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

7

Objects perhaps „know“ each other, that is there is some kind of relationship between the objects. Depending on the context, a relationship is called link or association or generalisation.

Examples:Cow ‚Elisabeth‘ is the daughter of cow ‚Victoria‘.Cow ‚Elisabeth‘ is suckling from ‚Victoria‘.A calf is a young cow.

Page 9: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

8

The behaviour of an object is described through one or more operations. They enable us to modify or request the object's state.

Object: Behaviour

getDigitalObject()

loadData()

Page 10: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

9

Every object has a distinct identity that is defined through its existence.

Object: Identity

Identity„Pseudo-Identity“

:Person :Person:Person :Person

:Person :Person :Person

Name=Michael Name=Michael

Name=John Name=John Name=John

Name=Mary Name=Linda

Page 11: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

10

The relations between objects can be visualised using an Object Diagram.

An Object Diagram describes objects, links and optionally attributes and their values at a specific point in time. An Object Diagram is a snaphot of a system or parts of it.

Object Diagram

Page 12: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

11

Example

Victoria:Cow

Elisabeth:Cow

Charles:Cow

Sex = mAge = 10

Page 13: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

12

A class represents a collection of objects. It defines the data structure (attributes), behaviour (operations) and relationships of the single objects.

Every object belongs to exactly one class.

Class

Page 14: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

13

UML representation of a class

Class

Class

Class

:DigitalObject

Attribute

Operation

Class

Attribute

Class

Operation

ID=1234DOType : IntegerREFNO=Q34R

ID=1234DOI=123.456

REFNO=Q34R

:DigitalObject

ID=5678DOType : IntegerREFNO=Q56S

DigitalObject

IDDOTypeREFNO

getDigitalObject()

Page 15: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

14

Attributes describe the properties of an object (class).

Attributes represent the data structure of an object (class).

All objects of a class share the same attributes. They differ in the values of the particular attributes.

Every attribute has a distinct type.

Attribute

Page 16: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

15

UML syntax for attributes

Attribute DigitalObject

ID ID: int ID: int {read only}

ID: int = 1234 ID: int [1] ID / ID

int ID

attribute attribute: type attribute: type {property string}attribute: type = Inital value attribute: type [x..y] class scope attribute /derived attribute type attribute

not normative!

Page 17: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

16

Operations are the actions that a class (the objects of a class) can carry out.

All objects of a class use the same operations.

All operations together represent the behaviour of the class (the objects).

Operation

Page 18: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

17

UML syntax for operations

Operation

name (parameter-list) : return-type {property-string}

assignID (int: ID) : void {read-only}

Page 19: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

18

Objects can be linked to each other. Classes can also be linked. This is called association.

Association

:DigitalObject

DigitalObject Date

:Date:DigitalObject

:Date

association

Page 20: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

19

Binary / Reflexive Association

CollectionDigitalObject11..*

DigitalObject

Reflexive A.

Binary A.

Page 21: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

20

Multiplicity

Multiplicities enable to model the number of possible links between objects of classes.

CollectionDigitalObject11..*

Multiplicities

Page 22: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

21

Examples for multiplicities

exactly one 1

one or none 0..1

uspecified number *

n to many 2..*

n to n 12..49

Page 23: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

22

An association can be labeled by using a verb phrase:

CollectionDigitalObject11..*

is part of

Page 24: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

23

An association can also be labeled by a property name

(role).

DigitalObject master

1

copy1..3

property names

Page 25: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

24

Associations can be completed by constraints.

DigitalObject master

1

copy1..3

constraint

{integrity checked}

Page 26: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

25

Aggregation and Composition

Aggregation and Composition are concepts for modelling a „whole-part“ relationship.

Example: „ A page is part of a book.“

They are both special kinds of association. They can also always be expressed as simple associations.

Page 27: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

26

Aggregation

UML syntax:

Collection DigitalObject

aggregated class

aggregation

partial class

Page 28: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

27

Collection DigitalObject

Collection DigitalObject1..*

1..*

1..* 1..*

is part of

Page 29: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

28

Composition

UML syntax:

Collection DigitalObject

aggregated class

composition

partial class

Page 30: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

29

Collection DigitalObject

Collection DigitalObject1..*

1 1..*is part of

Page273

Book

title=„UML“

Page 31: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

30

Navigability of associations

The navigabilty specifies the access to objects of given classes.

classX classY

classX

classX

classX

classY

classY

classY

unspecified

unidirectional

bidirectional

excluded navigability

Page 32: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

31

Properties modelled as attributes or associations

DigitalObject

ID: int [1]created: Date [1..*]

composed: File [1..*]

Digital Object

FileDate

1

1..*

1

1

Page 33: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

32

A generalisation describes a relationship between a super class and a sub class.

The sub class is a specialised class in regard of the super class. It is entirely consistent with the super class, but it adds some additional attributes or operations.

Every object of the sub class can be described with an „is a“ relationship.

Generalisation

Page 34: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

33

Page 35: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

34

Abstract Class

Page 36: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

35

A package is used to merge elements of models, especially classes.

They can be grouped in practicable units.

Packages are a good concept for describing the structure of a system on an abstract level.

A complete software system is at its highest level one big package.

Package

Page 37: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

36

Page 38: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

37

Visibility

Attributes and operations within a class can be labeled by a visibility indicator.

The same is valid for roles in associations.

Most common are „+“, that stands for public and

„-“ that stands for private.

Public elements can be used by any other class, private elements only by the class that owns them.

Additional features

Page 39: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

38 Notes

There is a possibility to insert comments into any UML diagram using the following graphical elements:

Page 40: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

39

DigitalObject

- ID

- RefNo

- CatType

- checkIntegrity()

+ getDigitalObject()

DigitalObject

AccessUnit

+ copy

*

*

Visibility: Attribute, Operation and property name

Page 41: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

40

Dependency

A dependency indicates changes to one element caused by changes of the other.

UML allows the usage of dependencies for all sorts of elements.

AccessUnit DigitalObject

dependency

Page 42: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

41

Dependencies can be detailed using a keyword.

AccessUnit DigitalObject<<call>>

Page 43: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

42

Often, relationships imply dependencies.

AccessUnit DigitalObject**

Report Document

Page 44: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

43

„If someone were to come up to you in a dark alley and say, ‚Psst, wanna see a UML diagram?‘ that diagram would probably be a class diagram.“

(Martin Fowler, „UML Destilled“)

Class diagram

Page 45: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

44

The Class Diagram represents a static view of a system.

Therefore Class Diagrams are often used to model structural issues like the architecture of a system or parts of it.

The Class Diagram models single components of the system or parts of it and describes its relationships.

It can be a starting point for transforming the systems model into programming code.

Class Diagram

Page 46: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

45

Example 1 – Part of system architecture

Source: http://bdn.borland.com/

Page 47: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

46

Example 2 - Conceptual Model: Taxonomy

Source:http://www.agilemodeling.com

Page 48: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

47

Example 3 – Producing software

class Person { protected string name; public void generateAddress();} class Foreigner extends Person {}

class Citizen extends Person {}

Page 49: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

48

More static views

Package Diagram

Package diagrams are often used to show the static structure of large systems on a high level.

<<call>>

Page 50: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

49

So far we regarded the static and structural side of systems.

UML offers some more diagrams for modelling behavioural and dynamic aspects of systems.

Behavioural diagrams show systems in action.

Behavioural and Dynamic Aspects: More UML Diagrams

Page 51: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

50

A system in action can be described as one that has at any given time a set of defined states .

States change in a time span. This is called transition.

The UML diagram that describes states of a system or of elements of it (i.e. of particular objects) at a given time (span) is called State Machine Diagram.

State Machine Diagram

Page 52: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

Example

51

Core graphical elements

final state

inital statesub-state pointer

transition arrow

event

State box

decision node

Page 53: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

Example (2)

52

entry activityexit activity

fork

join

Page 54: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

53

A transition can be labelled in three parts (optional):

openkey turned [unblocked] /open door

trigger activity

guard condition

Page 55: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

54

Activity State: States with an ongoing activity

Query sentWorking

do/ search for entry

Page 56: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

55

Activity Diagrams provide a technique for describing work flows or procedures of a system.

An Activity Diagram shows the system in action in a more general view, not regarding just one particular object, but a sequence of actions where different objects may be involved.

Activity Diagram

Page 57: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

56

Initial node

action

exception

objectactivity final

condition

decision

Errorflow

Page 58: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

57

A Communication (Collaboration) Diagram is a technique

to show how messages flow between particular objects.

It visualises the interactions between the objects and shows how the objects are linked together.

The Sequence Diagram is an alternative kind of Interaction Diagram besides the Communication Diagram.

Communication Diagram

Page 59: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

58

Notation features

link

dataflow arrow

(flat) numbering object

self link

Page 60: Introduction to the Unified Modeling Language (UML) Delos NoE, Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford.

59

Fowler, Martin: UML destilled (3d edition), 2004.

OMG: Unified Modeling Language (UML), Version 2.0 .

Link (01. Feb. 2006): http://www.omg.org/technology/documents/formal/uml.htm

(= Specification of the UML)

Balzert, Heide: Lehrbuch der Objektmodellierung, 2005.

References