Software Architecture and Design
• Discuss what are UML Diagrams?
• What are types of UML Diagrams?
Today’s Agenda • What is Class Diagram?
• Activity (Case Study)
• A UML diagram is a diagram based on
the UML (Unified Modeling Language)
with the purpose of visually
What is UML representing a system along with its
Diagram? main actors, roles, actions, artifacts or
classes, in order to better understand,
alter, maintain, or document
information about the system.
What are the types of UML Diagrams?
What is a Class Diagram?
• In software engineering, a class diagram in
the Unified Modeling Language (UML) is a
type of static structure diagram that
describes the structure of a system by
showing the system's classes, their
attributes, operations (or methods), and
the relationships among objects.
Essential elements of class diagram
Class Name
Attributes
Operations
Class Name
Rules to • A class name should always start with a capital
letter.
represent
• A class name should always be in the center of
the first compartment.
• A class name should always be written in bold
a class format.
• UML abstract class name should be written in
name: italics format.
Attributes characteristics
• The attributes are generally written
along with the visibility factor.
• Public, private, protected and package
are the four visibilities which are
Attributes denoted by +, -, #, or ~ signs respectively.
• Visibility describes the accessibility of an
attribute of a class.
• Attributes must have a meaningful name
that describes the use of it in a class.
There are mainly three kinds of
relationships in UML:
Relationships • Dependencies
• Generalizations
• Associations
• A dependency means the
relation between two or more
classes in which a change in
one may force changes in the
Dependency other. However, it will always
create a weaker relationship.
• Dependency indicates that
one class depends on another.
• In an e-commerce application, a Cart class depends on a Product class
because the Cart class uses the Product class as a parameter for an add
operation. In a class diagram, a dependency relationship points from
the Cart class to the Product class.
• In UML modeling, a generalization
relationship is a relationship in
which one model element (the
child) is based on another model
element (the parent).
Generalization • The parent model element can have
one or more children, and any child
model element can have one or
more parents. It is more common to
have a single parent model element
and multiple child model elements.
Single parent with a single child Single parent with multiple children
Association
• Association is the most commonly used relationship between a
class and a class, which means that there is a connection
between one type of object and another type of object.
Multiplicity
• A multiplicity allows for statements about the number of objects
that are involved in an association.
Example
Aggregation Relationship
• Aggregation implies a relationship where the child can
exist independently of the parent.
• Example: Class (parent) and Student (child). Delete the
Class and the Students still exist.
Composition Relationship
• Composition implies a relationship where the child
cannot exist independent of the parent.
• Example: House (parent) and Room (child). Rooms don't
exist separate to a House.