Presentation is loading. Please wait.

Presentation is loading. Please wait.

And Some Of Their Elements

Similar presentations


Presentation on theme: "And Some Of Their Elements"— Presentation transcript:

1 And Some Of Their Elements
UML Diagrams & And Some Of Their Elements

2 Building blocks of the UML
As part of a model you have: modelling elements relationships between the modeling elements diagrams that group and visualize the modeling elements and the relations between them. E.g. class diagram: Company Department Office * 1 1..* LocatedAt

3 Comment You can add comments on all type of diagrams, attaching them to all kinds of elements. Semantically insignificant.

4 UML 2.0 The taxonomy of diagrams
“Structure diagrams show the static structure of the objects in a system. That is, they depict those elements in a specification that are irrespective of time... example, a structure diagram for an airline reservation system may include classifiers that represent tickets.” Diagram Structure Diagram Behaviour Diagram “Behavior diagrams show the dynamic behavior of the objects in a system, including their methods, collaborations, activities and state histories. The dynamic behavior of a system can be described as a series of changes to the system over time... the boundaries between the various kinds of diagram types are not strictly enforced.” Moment and Movement!!

5 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. StateChart D. Composite Structure D. Interaction D. Sequence D. Component D. Composite Structure Diagram Ref.Man. UML2.0: ”A diagram that shows the internal structure of a structured classifier or a collaboration. There is no rigid line between a composite structure diagram and a general class diagram.” Communication D. Deployment D. Interaction Overview D. Timing D.

6 Grouping Elements You can group elements with the help of packages and by this organize your classes, diagrams, etc. java applet +Applet

7 Dependency: A relationship between two modeling elements indicates that a change in the destination may effect the source. Example – dependency between classes: Company is dependent on Employee Company add(e : Employee) Employee The operation add has an employee object as argument: A change in Employee may inflict a change of the add operation.

8 Dependency on Package Diagram
From MagicDraw

9 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. StateChart D. Composite Structure D. Interaction D. Sequence D. Component D. Composite Structure Diagram Ref.Man. UML2.0: ”A diagram that shows the internal structure of a structured classifier or a collaboration. There is no rigid line between a composite structure diagram and a general class diagram.” Communication D. Deployment D. Interaction Overview D. Timing D.

10 Stereotype From Wikipedia “Allow designers to extend the vocabulary of UML in order to create new model elements, derived from existing ones, but that have specific properties that are suitable for a particular problem domain or otherwise specialized usage.”

11 Some Extensibility Mechanisms
«container» EventQueue {version 2.1} tagged value add(e:event) remove(n:int) «query» length():int «helper function» reorder() {add runs in O(1) time} stereotype constraint (not expressed in OCL)

12 Class: Describes a Set of Objects
class name attributes compartment operations compartment visibility operation signature Point - x : int - y : int + getX() : int + setX(aX : int) : void + getY() : int + setY(aY : int) : void Modelling tool: Rational Rose 2000 Coming slides will say more about visibility… Additional compartments may be supplied, e.g., a constraints compartment.

13 Attribute (Implemented as Field in Java, data member in C++)
[5] ”An attribute is the description of a named slot of a specified type in a class; each object of the class separately holds a value of the type.” <<stereotype>>opt / optvisibilityopt name multiplicityopt : typeopt … Used if the value of the attribute can be derived from other information. - (private) only the class can see this attribute # (protected) only the class and all of its subclasses + (public) all classes that can see the class can also see the attribute ~ (package) only classes in the package can see the attribute E.g. <<unique>> Example: Circle: attribute radius, circumference can de derived (2 x pi x radius) position: x, y with default values 0

14 Attribute continues Example: Tagged value e.g. Author = Kari … name multiplicityopt : typeopt = initial-valueopt {property-string}opt Example: [1..*] : String Indicating one or more addresses. (If no is present you will still have the empty string (””).) If [0..*] : String is specified, then can be null. Example: Circle: attribute radius, circumference can de derived (2 x pi x radius) position: x, y with default values 0

15 Operation (Implemented as method in Java, as member function in C++)
[5]: ”An operation is a specification of a transformation or query that an object may be called to execute…. A method is a procedure that implements an operation. It has an algorithm or procedure description.” Examples: + <<query>> getX() : double + setX(newX : double) <<stereotype>>opt visibilityopt name(parameter-list) : return-typeopt

16 Encapsulation (Information Hiding)
Point - x : int - y : int + getX() : int + setX(aX : int) : void + getY() : int + setY(aY : int) : void Hiding design decisions in a computer program that are most likely to change. E.g.: Store data in slots or Calculate them or Retrieve them from a database? Wanted effect: Protection of other parts of the program from extensive modification if the design decision is changed. Realized by having the attributes private/protected and supplying public operations to access the hidden data. Also concurrency…

17 Static Features (i.e., attributes and operations)
Features are usually defined for instances of the class (e.g., an attribute gives a slot for each instance of the class). Static or class scoped features are also possible: The class is then like an object with these features. No object of the class is needed to use. Static features are underline in UML. [8]

18 Association Classes The association between classes may have attributes of its own. This can be modeled by connecting a class to the association. Institute Person works for Job description salary Eclipse Modeling Tools

19 Different Model Same Information [2]
Reified Association

20 Reification To treat as an object something that normally is not considered an object. Example: Association class ~ “links as objects” – links are often considered to have no internal structure, association classes allows internal structures to be defined. Another example: Invocation / activation. Actually also words reifying abstract concepts…

21 Active Class Snake pos:Point move() bite() Active class: Describes objects that owns their own thread. The behavior of these objects can be concurrent with others. It does not seems like MagicDraw supports this!? BOUML notation:

22 Association A relationship that describes a set of links between classes of objects, indicating some sort of connection between objects of the involved classes. Example: student follows a course. In UML class diagrams you can distinguish between ordinary association, simple aggregation and composition (strong aggregation).

23 Ordinary Association:
This relationship indicate that there is a connection from one type of objects to another type. From the UML 2.1 specification - semantic description of association : “An association declares that there can be links between instances of the associated types. A link is a tuple with one value for each end of the association, where each value is an instance of the type of the end.” Company association name composition or strong aggregation 1 1..* 1..* LocatedAt Department Office multiplicity * * ordinary association

24 Ordinary Assocaition With Navigability:
If you have a Quiz-object, the associated Question-objects can be directly reach from the Quiz-object. I.e., there will be a reference to each Question-object inside the Quiz-object but not the other way around. Quiz direction of navigation Question base class * 1..* association with navigation One possible mapping to Java class Quiz{ // A list of questions Question [] questions; .... } class Question { // no reference to Quiz .... }

25 Navigability And Use Of Rolename
E.g. implementation in Java: editAnswerAlternative() may contain the following code: rightAnswer.setTxt(”Some smart answer”) Role name Question rightAnswer AnswerAlternative 1 1 txt : String editAnswerAlternative() setTxt(txt : String)

26 A Class Diagram With Navigation
responsible for 1 * Course Person CourseModule name : String description : String name : String imail : String homePage : String 1 * * 1..* name : String description : String tech. responsible for 1 reached 1 * * 1 StudentCourseProfile * Student finished : boolean When a student register for course a StudentCourseProfile object will be made!

27 A Class Diagram - Mapping to Java
1 responsible for * Course Person -name : String -description : String #name : String #imail : String #homePage : String 1 tech. responsible for * 1 * * 1 StudentCourseProfile Student -finished : boolean public class Person { protected String name; protected String imail; protected String homePage; // // Navigation protected Course[] responsibleFor; protected Course[] techResponsibleFor; } public class Student extends Person { // // Navigation public StudentCourseProfile[] studentCourseProfile; }

28 Composition: Aggregation:
An important type of association is composition and aggregation which indicates that one object contains objects of a given type (i.e., a whole/part relationship). No cycles are allowed (over all compositions/aggregations) and it should be understood to be a transitive relation. Only binary associations can be aggregations. Composition aggregation (strong aggregation) Company Department 1 1..* aggregation Company Department 1 1..*

29 Composition: Company Department 1 1..*
UML 2.1 specification: “Composite aggregation is a strong form of aggregation that requires a part instance be included in at most one composite at a time. If a composite is deleted, all of its parts are normally deleted with it… Compositions may be linked in a directed acyclic tree with transitive deletion characteristics; that is, deleting an element in one part of the graph will also result in the deletion of all elements of the subgraph below that element.” Composition aggregation (strong aggregation) Company Department 1 1..*

30 2.2.3 Aggregation: This is a weaker form of aggregation than composition Unlike composition a part instance might be included in more than one aggregation at a time. Composition defines a directed tree and an aggregation defines a directed graph that does not have cycles. aggregation Address Mail 1 1..* MailBody 1 1

31 Generalization: Eagle
A relationship between a more general element and a more specific one. For example: A bird is also an animal. (Generalization is not an association, but it do relate objects in regard to classification.) Animal A bird is a specialization of an animal. It inherits the structure and behaviour of Animal. Bird Eagle Generalization is a transitive relation!

32 Realization: UML: ”A semantic relationships between classifiers, in which one classifier specifies a contract that another classifier guarantees to carry out”. <<interface>> Movable Snake inherits the behaviour specified by the operations of Movable (as an interface Movable has no internal structure). move(x,y) Snake move(x,y) The class Snake realises (implements) the interface Movable.

33 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. StateChart D. Composite Structure D. Interaction D. Sequence D. Component D. Communication D. Deployment D. Interaction Overview D. Timing D.

34 Object Diagram - Capture Instances and Links
Class Object Company HiA: Company noOfEmploees=600 noOfEmploees : int Possible object name object class slot with value

35 Object Diagram with Links
Class Diagram Object Diagram Language: Department :LocatedAt Gimlemoen: Office Company 1 HiA: Company 1..* LocatedAt Possible object diagram Department Office * 1..* Engineering : Department :LocatedAt Grooseveien: Office Link - A link is an instance of an association, analogous to an object being an instance of a class.

36 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. StateChart D. Composite Structure D. Interaction D. Sequence D. Component D. Composite Structure Diagram Ref.Man. UML2.0: ”A diagram that shows the internal structure of a structured classifier or a collaboration. There is no rigid line between a composite structure diagram and a general class diagram.” Communication D. Deployment D. Interaction Overview D. Timing D.

37 Composite Structure Diagram
[2] : ”A diagram that shows the internal structure of a structured classifier or a collaboration. There is no rigid line between a composite structure diagram and a general class diagram.”

38 Structured Classifier
Car :powers : Enginee front : Wheel 2 back : Wheel 2 [2] : ”A classifier containing parts or roles that form its data structure and realize its behavior.” Forhjulsdrevet = with front drive

39 From [6]: Alternative notation [6]:

40  A decomposition of a classifier into its properties, parts and relationships[9]:
Vault = Velv

41 Port An element that represents an externally visible part of a containing classifier instance. It may have state and perform actions, e.g., convert input from one format (e.g., C++) to another (e.g., Smalltalk). Ports define the interaction between a classifier and its environment in the form of provided interfaces and required interfaces.

42 Collaboration Written Examination Examination Candidate : Student examinant : Employee exam : Exam : ExaminationCertificate student delivery: WrittenDocument : ExaminationPaper : Place [2]: ”A specification of a contextual relationship among instances that interact within a context to implement a desired functionality.”

43 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. State Machine D. Composite Structure D. Interaction D. Sequence D. Component D. Communication D. Deployment D. Interaction Overview D. Timing D.

44 Component diagram Captures the Physical Structure of the Implementation
applet1.class applet1.java Demo.html applet2.class applet2.java logo.gif

45 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. StateChart D. Composite Structure D. Interaction D. Sequence D. Component D. Communication D. Deployment D. Interaction Overview D. Timing D.

46 Deployment Diagram Extended WLAN << Server >>
<<Network >> LAN ”PC” ”PC”

47 Multi-tier Architecture - MVC - view: browser/jsp/servlet controller: jsp/servlet model: businessObjects + DB client: Internet browser: server1: :WebServer :html :html :ServletContainer Intranet s1:Servlet s2:Servlet j1:Jsp j2:Jsp b1:BusinessObject b3:BusinessObject b2:BusinessObject b4:BusinessObject server2: :DB

48 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. State Machine D. Composite Structure D. Interaction D. Sequence D. Component D. Communication D. Deployment D. Interaction Overview D. Timing D.

49 Activity diagram - Capture Dynamic Behaviour (Activity-oriented) [2]
BoxOffice = place for managing tickets, e.g. tickets for concert.

50 Activity Diagram With Swim Lanes

51 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. StateChart D. Composite Structure D. Interaction D. Sequence D. Component D. Composite Structure Diagram Ref.Man. UML2.0: ”A diagram that shows the internal structure of a structured classifier or a collaboration. There is no rigid line between a composite structure diagram and a general class diagram.” Communication D. Deployment D. Interaction Overview D. Timing D.

52 ”A use case is a specific way of using the system by performing some part of the functionality. Each use case constitutes a complete course of events initiated by an actor, and it specifies the interaction that takes place between an actor and the system....” I. Jacobson

53 Use case diagram actor register a person
association use case system boundary include relationship (stereotype) register a person edit a registration/ delete a registration User navigate/view the register «include» view next person view previous person «include» Include is used to define functionality that is common to several use cases – it’s a modularization technique.

54 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. StateChart D. Composite Structure D. Interaction D. Sequence D. Component D. Composite Structure Diagram Ref.Man. UML2.0: ”A diagram that shows the internal structure of a structured classifier or a collaboration. There is no rigid line between a composite structure diagram and a general class diagram.” Communication D. Deployment D. Interaction Overview D. Timing D.

55 Statechart Diagram Microwave Owen as Example

56 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. StateChart D. Composite Structure D. Interaction D. Sequence D. Component D. Communication D. Deployment D. Interaction Overview D. Timing D.

57 Interaction User: :Oven-control -unit :Oven-light SetTemperature(250C) heatOn() lightOn() Interaction: A behaviour that comprises a set of messages sent between a set of objects to archive a special purpose, like in a sequence diagram.

58 Synchronous & Asynchronous Message Communication
Asynchronous flow of control: the sender continue its execution as soon as the message has been sent Synchronous flow of control: the sender is blocked until it receives a reply (e.g., procedural call in C, …).

59 Sequence Diagram Example:
object message activation bar life line

60 [2] Sequence Diagram with Asynchronous Flow of Control
sequence diagram (sd) asynchronous communication is when the sender does not wait for the reply of the message sent

61 [2] One More Sequence Diagram with Conditional Fragment

62 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. StateChart D. Composite Structure D. Interaction D. Sequence D. Component D. Communication D. Deployment D. Interaction Overview D. Timing D.

63 Communication diagram
Focus is on objects, links and flow of messages!

64 [5] Communication Diagram Example

65 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. StateChart D. Composite Structure D. Interaction D. Sequence D. Component D. Composite Structure Diagram Ref.Man. UML2.0: ”A diagram that shows the internal structure of a structured classifier or a collaboration. There is no rigid line between a composite structure diagram and a general class diagram.” Communication D. Deployment D. Interaction Overview D. Timing D.

66 Interaction Overview Diagram
[2]: ”A variation on an activity diagram incorporating sequence diagram fragments together with flow of control constructs.” [7]

67 Interaction Overview D.
Diagram Structure D. Behaviour D. Package D. Activity D. Class D. Use Case D. Object D. StateChart D. Composite Structure D. Interaction D. Sequence D. Component D. Communication D. Deployment D. Interaction Overview D. Timing D.

68 Timing Diagrams [3] Timing diagrams (UML 2.0) are a specific type of interaction diagram, where the focus is on timing constraints. Timing diagrams are used to explore the behaviors of objects throughout a given period of time. [4] The different states of the traffic light are shown

69 References [1] Grady Booch, James Rumbaugh and Ivar Jacobson: The Unified Modeling Language User Guide. Addison-Wesley, 1999 [2] James Rumbaugh, Ivar Jacobson and Grady Booch: The Unified Modeling Language Reference Manual Second Edition. Addison-Wesley, 2005 [3] [4] [5] Ref: [6] [7] Accessed 7th September 2011: [8] Accessed 7th September 2011: [9] Accessed 12th September 2013:


Download ppt "And Some Of Their Elements"

Similar presentations


Ads by Google