600 likes | 765 Views
Introduction to the Unified Modeling Language (UML). Delos NoE , Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford Internet Institute. Introductory Quotations. 1.
E N D
Introduction to the Unified Modeling Language (UML) Delos NoE , Preservation Cluster Workshop: Persistency in Digital Libraries 13. February 2006, Oxford Internet Institute
Introductory Quotations 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“)
UML – what is it good for? 2 • 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
Basic concepts: What is an object? 3 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.
4 An object can be featured by • State • Behaviour • Identity
5 UML Representation of an object elisabeth elisabeth:Cow :Cow object:Class
Object: State 6 The state of an object includes its attributes and its relationships to other objects. An attribute can have a value. :Cow :Cow Object:Class Colour = brown Age Colour : string Age : integer = 5 Attribute : type= value
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.
Object: Behaviour 8 The behaviour of an object is described through one or more operations. They enable us to modify or request the object's state. getDigitalObject() loadData()
Object: Identity 9 Every object has a distinct identity that is defined through its existence. :Person :Person :Person :Person Name=Michael Name=Mary Name=Michael Name=Linda Identity „Pseudo-Identity“ :Person :Person :Person Name=John Name=John Name=John
Object Diagram 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.
11 Example Charles:Cow Victoria:Cow Sex = m Age = 10 Elisabeth:Cow
Class 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.
13 UML representation of a class Class :DigitalObject :DigitalObject ID=1234 DOType : Integer REFNO=Q34R ID=5678 DOType : Integer REFNO=Q56S Attribute ID=1234 DOI=123.456 REFNO=Q34R Operation Class DigitalObject ID DOType REFNO Class Class Class Attribute Operation getDigitalObject()
Attribute 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.
15 UML syntax for attributes Attribute DigitalObject attribute attribute: type attribute: type {property string} attribute: type = Inital value attribute: type [x..y] class scope attribute /derived attribute type attribute ID ID: int ID: int {read only} ID: int = 1234 ID: int [1] ID / ID int ID not normative!
Operation 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 17 UML syntax for operations name (parameter-list) : return-type {property-string} assignID (int: ID) : void {read-only}
Association 18 Objects can be linked to each other. Classes can also be linked. This is called association. :DigitalObject :Date :DigitalObject :Date DigitalObject Date association
19 Binary / Reflexive Association DigitalObject Collection 1..* 1 Binary A. DigitalObject Reflexive A.
20 Multiplicity Multiplicities enable to model the number of possible links between objects of classes. Multiplicities DigitalObject Collection 1..* 1
21 Examples for multiplicities exactly one 1 one or none 0..1 uspecified number * n to many 2..* n to n 12..49
22 An association can be labeled by using a verb phrase: DigitalObject Collection 1..* 1 is part of
23 An association can also be labeled by a property name (role). DigitalObject master 1 1..3 copy property names
24 Associations can be completed by constraints. constraint DigitalObject master 1 1..3 {integrity checked} copy
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.
26 Aggregation UML syntax: Collection DigitalObject aggregation partial class aggregated class
27 Collection DigitalObject 1..* 1..* Collection DigitalObject 1..* 1..* is part of
28 Composition UML syntax: Collection DigitalObject composition partial class aggregated class
29 Collection DigitalObject 1..* Collection DigitalObject is part of 1 1..* Page Book 273 title=„UML“
30 Navigability of associations The navigabilty specifies the access to objects of given classes. unspecified classX classY unidirectional classX classY bidirectional classX classY excluded navigability classX classY
31 Properties modelled as attributes or associations DigitalObject Digital Object ID: int [1] created: Date [1..*] composed: File [1..*] 1 1 1 1..* Date File
Generalisation 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.
Package 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.
Additional features 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.
38 Notes There is a possibility to insert comments into any UML diagram using the following graphical elements:
39 Visibility: Attribute, Operation and property name DigitalObject DigitalObject * + copy - ID - RefNo - CatType - checkIntegrity() * + getDigitalObject() AccessUnit
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
41 Dependencies can be detailed using a keyword. <<call>> AccessUnit DigitalObject
42 Often, relationships imply dependencies. * * AccessUnit DigitalObject Report Document
Class diagram 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 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.
45 Example 1 – Part of system architecture Source: http://bdn.borland.com/
46 Example 2 - Conceptual Model: Taxonomy Source:http://www.agilemodeling.com
47 Example 3 – Producing software class Person { protected string name; public void generateAddress();} class Foreigner extends Person {} class Citizen extends Person {}
More static views 48 Package Diagram Package diagrams are often used to show the static structure of large systems on a high level. <<call>>
Behavioural and Dynamic Aspects: More UML Diagrams 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.