UNIT I UML DIAGRAMS
UNIT I UML DIAGRAMS
• Association: A relationship between two classes, often shown with a line connecting
the two classes.
• Multiplicity: Specifies how many instances of a class can be associated with one
instance of another class. (e.g., 1..*, 0..1)
• Aggregation: A special type of association that represents a "whole-part" relationship.
Shown with a hollow diamond at the "whole" end.
• Composition: A stronger form of aggregation, where the part cannot exist without the
whole. Shown with a filled diamond.
• Inheritance/Generalization: A relationship where one class (child) inherits from
another (parent). Represented by a line with a hollow triangle pointing to the parent
class.
• Dependency: A weaker relationship indicating that one class uses another. Shown as a
dashed arrow.
Example:
Imagine a simple system with the following classes: Person, Student, and Teacher.
+---------------------+
| Person |
+---------------------+
| -name: String |
| -age: int |
+---------------------+
| +getDetails(): void |
Inheritance: Student and Teacher inherit from
+---------------------+ Person.
▲ Attributes: Each class has its attributes (name,
| age, studentID, teacherID).
|
Methods: Operations like getDetails(), enroll(),
+-------------------+ +--------------------+
and teach() define behavior
| Student | | Teacher |
+-------------------+ +--------------------+
| -studentID: int | | -teacherID: int |
+-------------------+ +--------------------+
| +enroll(): void | | +teach(): void |
+-------------------+ +--------------------+
Interaction Diagrams (12 Marks)
Interaction Diagrams in UML (Unified Modeling Language) are used to
visualize the flow of control and data among different components or
objects in a system. They are crucial in modeling how objects collaborate to
achieve a particular behavior or functionality. The two primary types of
interaction diagrams are Sequence Diagrams and Communication Diagrams.
Both depict interactions but in slightly different ways.
1. Sequence Diagrams
A Sequence Diagram shows the interaction between objects arranged in a time
sequence. It represents how objects or components in the system exchange
messages or signals over time.
Key Components of Sequence Diagrams:
1. Lifeline: A vertical dashed line representing the existence of an object over
time.A lifeline represents an individual participant in a sequence diagram. A
lifeline will usually have a rectangle containing its object name. If its name is
"self", that indicates that the lifeline represents the classifier which owns the
sequence diagram.
Sometimes a sequence diagram will have a lifeline with an actor element
symbol at its head. This will usually be the case if the sequence diagram is
owned by a use case. Boundary, control and entity elements from
robustness diagrams can also own lifelines.
Messages
Messages are displayed as arrows. Messages can be complete, lost or found;
synchronous or asynchronous; call or signal. In the following diagram, the
first message is a synchronous message (denoted by the solid arrowhead)
complete with an implicit return message; the second message is
asynchronous (denoted by line arrowhead), and the third is the
asynchronous return message (denoted by the dashed line).
Execution Occurrence
A thin rectangle running down the lifeline denotes the execution occurrence, or activation
of a focus of control. In the previous diagram, there are three execution occurrences. The
first is the source object sending two messages and receiving two replies; the second is
the target object receiving a synchronous message and returning a reply; and the third is
the target object receiving an asynchronous message and returning a reply.
Self Message