Lecture Series (Class and Object Diagram
Lecture Series (Class and Object Diagram
UML Diagrams
UML diagrams are the ultimate output of the entire discussion. All the elements, relationships are
used to make a complete UML diagram and the diagram represents a system.
The visual effect of the UML diagram is the most important part of the entire process. All the
other elements are used to make it complete.
UML includes the following nine diagrams, the details of which are described in the subsequent
chapters.
● Class diagram
● Object diagram
● Use case diagram
● Sequence diagram
● Collaboration diagram
● Activity diagram
● Statechart diagram
● Deployment diagram
● Component diagram
Structural Diagrams
The structural diagrams represent the static aspect of the system. These static
aspects represent those parts of a diagram, which forms the main structure and are
therefore stable.
These static parts are represented by classes, interfaces, objects, components, and
nodes. The four structural diagrams are −
● Class diagram
● Object diagram
● Component diagram
● Deployment diagram
Class Diagrams
1. Class Name
2. Attributes
3. Operations
Class Name
The name of the class is only needed in the graphical representation of the class.
It appears in the topmost compartment. A class is the blueprint of an object which
can share the same relationships, attributes, operations, & semantics. The class is
rendered as a rectangle, including its name, attributes, and operations in separate
compartments.
Attributes characteristics:
● The attributes are generally written along with the visibility factor.
● Public, private, protected and package are the four visibilities which are
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.
Class Operations (Methods)
❖ Operations are shown in the third partition. They are services the
class provides.
❖ The return type of a method is shown after the colon at the end of
the method signature.
❖ The return type of method parameters is shown after the colon
following the parameter name.
❖ Operations map onto class methods in code.
Relationships in Class Diagrams
Classes are interrelated to each other in specific ways. In particular, relationships in
class diagrams include different types of logical connections. The following are such
types of logical connections that are possible in UML:
● Dependency
● Association
● Directed Association
● Reflexive Association
● Multiplicity
● Aggregation
● Composition
● Inheritance/Generalization
● Realization
Dependency
A dependency means the relation between two or more classes in which a change in
one may force changes in the other. However, it will always create a weaker
relationship. Dependency indicates that one class depends on another.
Let's say that that there are 100 students in one college. The college can have multiple
students.
Aggregation
For example, if college is composed of classes student. The college could contain
many students, while each student belongs to only one college. So, if college is
not functioning all the students also removed .
Purpose of Class Diagrams
The purpose of class diagram is to model the static view of an application. Class
diagrams are the only diagrams which can be directly mapped with object-oriented
languages and thus widely used at the time of construction.
UML diagrams like activity diagram, sequence diagram can only give the sequence
flow of the application, however class diagram is a bit different. It is the most popular
UML diagram in the coder community.
The purpose of the class diagram can be summarized as −
● Analysis and design of the static view of an application.
● Describe responsibilities of a system.
● Base for component and deployment diagrams.
● Forward and reverse engineering.
How to Draw a Class Diagram?
Basically, Class diagrams are the most popular UML diagrams used for
construction of software applications. It is very important to learn the drawing
procedure of class diagram.
Class diagrams have a lot of properties to consider while drawing but here the
diagram will be considered from a top level view.
Class diagram is basically a graphical representation of the static view of the
system and represents different aspects of the application. A collection of class
diagrams represent the whole system.
The following points should be remembered while drawing a class
diagram −
● The name of the class diagram should be meaningful to describe the
aspect of the system.
● Each element and their relationships should be identified in advance.
● Responsibility (attributes and methods) of each class should be clearly
identified
● For each class, minimum number of properties should be specified, as
unnecessary properties will make the diagram complicated.
● Use notes whenever required to describe some aspect of the diagram. At
the end of the drawing it should be understandable to the developer/coder.
● Finally, before making the final version, the diagram should be drawn on
plain paper and reworked as many times as possible to make it correct.
Where to Use Class Diagrams?
1. Conceptual perspective: Conceptual diagrams are describing things in the real world.
You should draw a diagram that represents the concepts in the domain under study. These
concepts related to class and it is always language-independent.
Object Names:
● Every object is actually symbolized like a rectangle, that offers the name from the object and its class
Object Attributes:
● Similar to classes, you are able to list object attributes inside a separate compartment. However,
unlike classes, object attributes should have values assigned for them.
Links:
● Links tend to be instances associated with associations. You can draw a link while
1. Before drawing an object diagram, one should analyze all the objects
inside the system.
2. The relations of the object must be known before creating the diagram.
3. Association between various objects must be cleared before.
4. An object should have a meaningful name that describes its
functionality.
5. An object must be explored to analyze various functionalities of it.
Applications of Object Diagrams:
1. Object diagrams play an essential role while generating a
blueprint of an object-oriented system.
2. Object diagrams provide means of modeling the classes, data
and other information as a set or a single unit.
3. It is used for analyzing the online or offline system. The
functioning of a system can be visualized using object diagrams.
Where to Use Object Diagrams?