Unit-2 Intro To UML - OOP
Unit-2 Intro To UML - OOP
B.Tech (CSE),GGSIPU,
M.Tech- IS, (AIACT&R, GGSIPU),
Ph.D.(P)-CSE, NIT Jalandhar
● UML is a standard language for specifying, visualizing, constructing, and
documenting the artifacts of software systems.
● UML was created by the Object Management Group (OMG) and UML 1.0
specification draft was proposed to the OMG in January 1997.
1. Things
2. Relationships
3. Diagrams
things
Anything that is a real world entity or object is termed as
things. It can be divided into several different categories:
● Structural things
● Behavioral things
● Grouping things
● Annotational things
strUctUral things
❖ Structural things define the static part of the model. In
other words, Nouns that depicts the static behavior of a
model is termed as structural things.
❖ They represent the physical and conceptual elements.
Use case −Use case represents a set of actions performed by a system for a specific
goal.
Message
❖ State Machine
It defines a sequence of states that an entity goes through in the software
development lifecycle. It keeps a record of several distinct states of a system
component.
varioUs states of state
Machine
relationships
It illustrates the meaningful connections between things. It shows the association between
the entities and defines the functionality of an application. There are four types of
relationships given below:
Dependency: Dependency is a kind of relationship in which a change in target element
affects the source element, or simply we can say the source element is dependent on the
target element. It is one of the most important notations in UML. It depicts the dependency
from one entity to another.
It is denoted by a dotted line followed by an arrow at one side as shown below,
Association: A set of links that associates the entities to the UML model. It
tells how many elements are actually taking part in forming that relationship.
It is denoted by a dotted line with arrowheads on both sides to describe the
relationship with the element on both sides.
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.
Aggregation vs. Composition
Abstract Classes
It is a class with an operation prototype, but not the implementation. It is also possible to have
an abstract class with no operations declared inside of it. An abstract is useful for identifying
the functionalities across the classes. Let us consider an example of an abstract class. Suppose
we have an abstract class called as a motion with a method or an operation declared inside of it.
The method declared inside the abstract class is called a move ().
This abstract class method can be used by any object such as a car, an animal, robot, etc. for
changing the current position. It is efficient to use this abstract class method with an object
because no implementation is provided for the given function. We can use it in any way for
multiple objects.
In UML, the abstract class has the same notation as that of the class. The only difference
between a class and an abstract class is that the class name is strictly written in an italic font.
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.
❖ Rational Rose
❖ Violet
❖ Umbrello(for linux)
❖ Visual Paradigm UML Suite
class diagraM
eXaMples
eXaMples of class diagraM
The following diagram is an example of an Order System of an application. It
describes a particular aspect of the entire application.
● First of all, Order and Customer are identified as the two elements of the
system. They have a one-to-many relationship because a customer can have
multiple orders.
● Order class is an abstract class and it has two concrete classes (inheritance
relationship) SpecialOrder and NormalOrder.
● The two inherited classes have all the properties as the Order class. In
addition, they have additional functions like dispatch () and receive ().
The following class diagram has been drawn considering all the points mentioned
above.
2nd eXaMple
Creating a class diagram is a straightforward process. It does not involve
many technicalities.
Here, is an example:
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:
The figure below provides an example of such a class diagram and its
corresponding object diagram:
sUMMary of object diagraM