Bai giang-uml-21jan14

9
Class Diagram elements Relationships among instances Association: An association is a relationship between the members of two classes Notation: An association is drawn as a solid line between two classes. 1

description

Bài giảng UML cho lớp 55PM1, Khoa Công nghệ thông tin, Trường Đại học Xây Dựng, ngày 21 tháng 01 năm 2014.

Transcript of Bai giang-uml-21jan14

Page 1: Bai giang-uml-21jan14

1

Class Diagram elements

● Relationships among instances

●Association: An association is a relationship between the members of two classes● Notation: An association is drawn as a solid line

between two classes.

Page 2: Bai giang-uml-21jan14

2

Class Diagram elements

● Relationships among instances

●Association● Association name: An association may have a

name. The name can be left empty.● Association end: An association has two ends. Each

end is the name a role, and is used to refer to the associated object

Page 3: Bai giang-uml-21jan14

3

Class Diagram elements

● Relationships among instances● Aggregation (Shared association) is an association

represents a shared ownership relationship. ● Notation: An aggregation is shown as binary

association decorated with a hollow diamond as a terminal adornment at the aggregate end of the association line

Page 4: Bai giang-uml-21jan14

4

Class Diagram elements

● Relationships among instances● Composition: An association represents a whole-part

relationship. A composition is a “strong” form of aggregation, if a composite (whole) is deleted, all of its composite parts are “normally” deleted with it.● Notation: Composite aggregation is depicted as a binary

association decorated with a filled black diamond at the aggregate (whole) end

Page 5: Bai giang-uml-21jan14

5

Class Diagram elements

● Relationships among classes

● Generalization: The specific class inherits part of its definition from the general class.● Notation: A generalization is shown as a line with a

hollow triangle as an arrowhead between the symbols representing the involved classifiers. The arrowhead points to the symbol representing the general classifier.

Page 6: Bai giang-uml-21jan14

6

Class Diagram elements

● Relationships among classes

● Realization: is a specialized abstraction relationship between two sets of model elements, one representing a specification (the supplier) and the other represents an implementation of the latter(the client).● Notation: A generalization is shown as a line with a

hollow triangle as an arrowhead between the symbols representing the involved classifiers. The arrowhead points to the symbol representing the general classifier

Page 7: Bai giang-uml-21jan14

7

Class Diagram elements

● Relationships among classes

● Dependency: is a relationship that signifies that a single or a set of model elements requires other model elements for their specification or implementation. This means that the complete semantics of the depending elements is either semantically or structurally dependent on the definition of the supplier element(s)● Notation: A dependency is shown as a dashed arrow

pointing from the client (dependent) at the tail to the supplier (provider) at the arrowhead.

Page 8: Bai giang-uml-21jan14

8

Class Diagram elements

● Multiplicity

● is a definition of cardinality, i.e., number of elements, is used to indicates how many of the objects at this end can be linked to each object at the other.

● Multiplicity interval has some lower bound and (possibly infinite) upper bound. Lower and upper bounds could be natural constants or constant expressions evaluated to natural (non negative) number. Upper bound ’*’ which denotes unlimited number of elements. Upper bound >= lower bound.

0..0/0: Collection must be empty; 0..1: No instances or one instance; 1..1/1: Exactly one instance; 0.. */*: Zero or more instances; 1..*: At least one instance; m..n: At least m but no more than n instances

Page 9: Bai giang-uml-21jan14

9

Class Diagram example

(created by Visual Paradigm for UML 10.2)