1. UNIT I UML DIAGRAMS
Introduction to OOAD – Unified Process –
UML diagrams – Use Case – Class Diagrams–
Interaction Diagrams – State Diagrams –
Activity Diagrams –
Package, component and Deployment Diagrams.
2. Class Diagram
A type of static structure diagram
that describes the structure of a system
3. Class Diagram
• Class diagram is a static diagram
– It represents the static view of an application
• Class diagram shows a collection of classes, interfaces, associations,
collaborations and constraints.
– It is also known as a structural diagram.
• Purpose of Class Diagram
– Analysis and design of the static view of an application.
– Describe responsibilities of a system.
– Base for component and deployment diagrams.
– Forward and reverse engineering.
4. Class Diagram
• A no. of classes are identified & grouped together in a class diagram
– That helps to determine the static relations between them.
• To further describe the behavior of systems,
– Class diagrams can be complemented by a state diagram or UML
state machine.
5. Notations in Class Diagram
• It shows the
1. Classes in a system,
2. Attributes and operations of each class and
3. Relationship between each class.
• Classes are represented as boxes with 3 sections
– Name at the top,
– Attributes in the middle and
– Operations or methods at
the bottom
6. Notations - Members Visibility
• To specify the visibility of a class member
(i.e. any attribute or method),
– These notations must be placed before the member's name
+ Public
- Private
# Protected
/
Derived (can be
combined with one
of the others)
~ Package
7. Relationships
• A relationship covers the specific types of logical connections
found on class and object diagrams.
• UML shows the following relationships:
8. Dependency
– Connection b/w dependent and independent model elements
– Dependency is represented by a dotted arrow
– Arrow head represents the independent element and the other end the
dependent element.
9. Association
• Represent the relationship b/w two elements of a system
– Describes how the elements in an UML diagram are associated
– Represented by a dotted line with (without) arrows on both sides
– Multiplicity is mentioned at the ends
10. Multiplicity in UML
• Multiplicity allows to specify cardinality
i.e. number of elements - of some collection of elements.
• Multiplicity interval has some lower bound and upper bound
• Some typical examples of multiplicity
Multiplicity Option Cardinality
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
5..5 5 Exactly 5 instances
m..n At least m but no more than n instances
11. Example
Two or more Player actors are required
to initiate Play Game use case.
Multiplicity of Players for Soccer Team class
12. Aggregation
• Aggregation is a special case of association.
• When an object ‘has-a’ another object,
– Then you have got an aggregation between them.
• Direction specifies which object contains the other object.
• Aggregation is also called a “Has-a” relationship
Example:
A Library contains students and books.
Relationship b/w library and student is aggregation.
13. Composition
• Composition is a special case of aggregation.
• When an object contains the other object,
– If the contained object cannot exist without the existence of container object, then it is called composition.
Folder could contain many files,
while each File has exactly one Folder parent.
If Folder is deleted, all contained Files are deleted as well.
Hospital has 1 or more Departments,
Each Department belongs to exactly one Hospital.
If Hospital is closed, so are all of its Departments.
Example:
A Library contains students and books.
Relationship between library and book is composition.
A student can exist without a library and therefore it is aggregation.
A book cannot exist without a library and therefore its a composition.
14. Generalization
• Generalization uses a “is-a” relationship
• At a very broader level you can understand this as inheritance.
Example:
Consider there exists a class named Person.
A student is a person.
A faculty is a person.
Here the relationship b/w student & person, similarly faculty & person is generalization.
shared target style.separate target style
15. Realization
• A realization relationship is a relationship between two model element
– One element (client) realizes (implements) the behavior that the other element (supplier) specifies.
• In OOP, realization represents the implementation of an interface by a class.