Unit 2
Unit 2
Composition is a stronger
form of aggregation,
indicating a more significant
ownership or dependency
relationship.
In composition, the part class
cannot exist independently
of the whole class.
Composition is represented
by a filled diamond shape on
the side of the whole class.
Generalization(Inheritance)
A usage dependency
relationship in a UML class
diagram indicates that one class
(the client) utilizes or depends
on another class (the supplier)
to perform certain tasks or
access certain functionality.
The client class relies on the
services provided by the
supplier class but does not own
or create instances of it.
How to draw Class Diagrams
Identify Classes
List Attributes and Methods
Identify Relationships
Create Class Boxes
Add Attributes and Methods
Draw Relationships
Label Relationships
Review and Refine
Use Tools for Digital Drawing
Use cases of Class Diagrams
System Design
Communication and Collaboration
Code Generation
Testing and Test Planning
Reverse Engineering
Object Diagrams
1. Determine the behavior for which the realization and implementation are
specified.
2. Discover the structural elements that are class roles, objects, and
subsystems for performing the functionality of collaboration.
1. Choose the context of an interaction: system, subsystem, use case, and operation.
3. Think through alternative situations that may be involved.
1. Implementation of a collaboration diagram at an instance level, if needed.
2. A specification level diagram may be made in the instance level sequence diagram
for summarizing alternative situations.
Components of a collaboration Diagram
Example of a Collaboration Diagram
Represent this polymorphic behavior using a
Collaboration diagrams
In a collaboration diagram, polymorphic behavior can be represented using
a combination of messages and actors. Let's consider an example where we
have a Shape base class and two subclasses, Circle and Rectangle. Both
subclasses implement a draw() method, but each subclass implements it
differently.
Here's how you can represent this polymorphic behavior in a collaboration
diagram:
Actor: The actor in this scenario could be a DrawingApp that interacts with
different shapes.
Messages: The messages represent the interactions between the
DrawingApp and the shapes.
In this diagram, DrawingApp sends a drawShape(shape) message to a
Shape object. The Shape object could be either a Circle or a Rectangle.
Depending on the type of the Shape object, the appropriate draw() method of
the specific subclass (Circle or Rectangle) is executed, demonstrating
polymorphic behavior.
Iterating and Conditional Messages