Software Architecture and Design-Class - Diagram
Software Architecture and Design-Class - Diagram
Class Name
Attributes
Operations
Class Name
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.