Misc Concepts-UML Class+Association Relationships 8

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Software Construction

Unified Modeling Language


Class Diagram and Relationships
UML Class Diagram
• Class diagram is used to represent the static diagram by
mapping the structure of the systems using classes, attributes,
relations, and operations between the various objects.
• A class diagram has various classes; each has three-part;
• the first partition contains a class name which is the name of the
class or entity which is participated in the activity,
• the Second partition contains class attributes that show the various
properties of the class,
• the third partition contains class operations which shows various
operations performed by the class
1. Class Diagram
• Class diagrams are the main building
block of any object-oriented solution. It
shows the classes in a system, attributes,
and operations of each class and the
relationship between each class.
• In most modeling tools, a class has three
parts. Name at the top, attributes in the
middle and operations or methods at
the bottom.
• Many related classes are grouped
together to create class diagrams.
• Different relationships between classes
are shown by different types of arrows.
Relationships
• In a class diagram relationships shows the relation between two classes.
• Relationship Types:
• Association
• Directed Association
• Reflexive Association
• Multiplicity
• Aggregation
• Composition
• Inheritance / Generalization
• Realization
Association
• Any logical connection or relationship
between classes.
• Shown by a simple connector line
• For example, Passenger and Airline or a
Student and School
Directed Association
• The directed association is concerned with the
direction of flow inside association classes.
• A directional relationship represented by a line
with an arrowhead.
• The arrowhead depicts a container-contained
directional flow.
• It can be said that there is an association
between a passenger and the airplane. The
Airplane carries Passengers not the passenger
carries airplane.
Reflexive Association
• A class having multiple functions or
responsibilities.
• Represented by a looping Link
• For example, a staff member working in an
airport may be a pilot, aviation engineer, a
ticket dispatcher, a guard, or a maintenance
crew member..
Multiplicity
• A logical association specifying the
cardinality of a class in relation to another
• It is specified by the domain range FROM ..
TO as 0..* meaning 0 to Many
• It describes the number of instances
allowed for a particular element by 0 No instances (rare)
providing an inclusive non-negative integers 0..1 No instances, or one instance
1 Exactly one instance
interval. It has both lower and upper 1..1 Exactly one instance
bound. 0..* Zero or more instances
* Zero or more instances
1..* One or more instances
Aggregation
• A particular class as a result of one class being
aggregated or built as a collection.
• For example, the class “library” is made up of
one or more books.
• In aggregation, the contained classes are not
strongly dependent on the lifecycle of the
container. In the same example, books will
remain so even when the library is dissolved.
• To show aggregation in a diagram, draw a line
from the parent class to the child class with a
unfilled diamond shape near the parent class.
Composition
• A particular class as a result of one class being
aggregated or built as a collection but the
dependence of the contained class to the life
cycle of the container class. That is, the contained
class will be destroyed when the container class is
destroyed.
• For example, a shoulder bag’s side pocket will also
cease to exist once the shoulder bag is destroyed.
• use a directional line connecting the two classes,
with a filled diamond shape adjacent to the
container class and the directional arrow to the
contained class.
• The composition relationship is very similar to the
aggregation relationship except its life cycle.
Inheritance / Generalization
• A type of relationship where one associated class is
a child of another by virtue of assuming the same
functionalities of the parent class. The child class is a
specific type of the parent class.
• To show inheritance use a solid line from the child
class to the parent class with an unfilled arrowhead.
• Example: A bank account can be of two types;
Savings Account and Credit Card Account. Both the
savings and the credit card account inherits the
generalized properties from the Bank Account,
which is Account Number, Account Balance, etc.
Realization
• The implementation of the functionality
defined in one class by another class.
• To show the relationship use a broken line
with an unfilled solid/filled arrowhead near
the class that defines the functionality of
the class that implements the function.
• For example, the printing preferences that
are set using the printer setup interface are
being implemented by the printer..
EXAMPLE
On bank ATMs, the customer is
authenticated by inserting a
plastic ATM card and entering a
personal identification number
(PIN).
Customer Authentication use
case is required for every ATM
transaction so we show it as
include relationship. Including
this use case as well as
transaction generalizations
make the ATM Transaction an
abstract use case.
EXAMPLE
ATM Technician maintains or
repairs Bank ATM.
Maintenance use case includes
Replenishing ATM with cash,
ink or printer paper, Upgrades
of hardware, firmware or
software, and remote or on-site
Diagnostics. Diagnostics is also
included in (shared with) Repair
use case.
A class diagram for sales order system:

ASSIGNMENT:

Identify and briefly


explain Relationships
given in this Class
Diagram

You might also like