And Some Of Their Elements UML Diagrams & And Some Of Their Elements
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
Comment You can add comments on all type of diagrams, attaching them to all kinds of elements. Semantically insignificant.
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!!
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.
Grouping Elements You can group elements with the help of packages and by this organize your classes, diagrams, etc. java applet +Applet
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.
Dependency on Package Diagram From MagicDraw
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.
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.”
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)
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.
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
Attribute continues Example: Tagged value e.g. Author = Kari … name multiplicityopt : typeopt = initial-valueopt {property-string}opt Example: email[1..*] : String Indicating one or more email addresses. (If no email is present you will still have the empty string (””).) If email[0..*] : String is specified, then email can be null. Example: Circle: attribute radius, circumference can de derived (2 x pi x radius) position: x, y with default values 0
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
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…
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]
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).
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
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 .... }
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)
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; }
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!
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.
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.
Object Diagram - Capture Instances and Links Class Object Company HiA: Company noOfEmploees=600 noOfEmploees : int Possible object name object class slot with value
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.
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.
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.
Activity diagram - Capture Dynamic Behaviour (Activity-oriented) [2] BoxOffice = place for managing tickets, e.g. tickets for concert.
Activity Diagram With Swim Lanes
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.
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.
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, …).
Sequence Diagram Example: object message activation bar life line
[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
[2] One More Sequence Diagram with Conditional Fragment
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.
Communication diagram Focus is on objects, links and flow of messages!
[5] Communication Diagram Example
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] http://en.wikipedia.org/wiki/UML_Timing_Diagram [4] http://www.altova.com/features_timing_diagram.html [5] Ref: http://dn.codegear.com/article/31863#sequence-diagrams [6] http://www.jot.fm/issues/issue_2004_11/column5/ [7] Accessed 7th September 2011: http://www.uml-diagrams.org/interaction-overview-diagrams-examples.html [8] Accessed 7th September 2011: http://www.uml-diagrams.org/class-diagrams.html [9] Accessed 12th September 2013: http://www.uml-diagrams.org/composite-structure-diagrams.html