OO Modelling
OO Modelling
Compiled By:
Hayelom M. (PhD Student at UESTC, China)
Components of OOP
• Encapsulation
– Is the process of binding both attributes and methods together
within a class.
– Through encapsulation, the internal details of a class can be
hidden from outside.
– It permits the elements of the class to be accessed from
outside only through the interface provided by the class.
• Polymorphism
– In object-oriented paradigm, polymorphism implies using
operations in different ways, depending upon the instance
they are operating upon.
– Polymorphism allows objects with different internal
structures to have a common external interface.
– Polymorphism is particularly effective while implementing
inheritance.
Inheritance
• Inheritance is the mechanism that permits new classes
to be created out of existing classes by extending and
refining its capabilities.
• The existing classes are called the base classes/parent
classes/super-classes, and the new classes are called
the derived classes/child classes/subclasses.
• The subclass can inherit or derive the attributes and
methods of the super-class(es) provided that the
super-class allows so.
• Besides, the subclass may add its own attributes and
methods and may modify any of the super-class
methods.
• Inheritance defines an “is – a” relationship.
Class
• A class represents a collection of objects having
same characteristic properties that exhibit common
behavior. It gives the blueprint or description of the
objects that can be created from it. Creation of an
object as a member of a class is called instantiation.
Thus, object is an instance of a class.
• The constituents of a class are −
– A set of attributes for the objects that are to be instantiated
from the class. Generally, different objects of a class have
some difference in the values of the attributes. Attributes
are often referred as class data.
– A set of operations that portray the behavior of the objects
of the class. Operations are also referred as functions or
methods.
• A class is represented by a rectangle having three sections −
• The top section containing the name of the class
• The middle section containing class attributes
• The bottom section representing operations of the class
• The visibility of the attributes and operations can be represented in
the following ways −
• Public − it is prefixed by the symbol ‘+’.
• Private − it is prefixed by the symbol ‘−’.
• Protected − It is prefixed by the symbol ‘#’.
Class representation
Object
• An object is a real-world element in an object–oriented
environment that may have a physical or a conceptual
existence. Each object has −
– Identity that distinguishes it from other objects in the
system.
– State that determines the characteristic properties of an
object as well as the values of the properties that the object
holds.
– Behavior that represents externally visible activities
performed by an object in terms of changes in its state.
• Objects can be modelled according to the needs of the
application.
• An object may have a physical existence, like a
customer, a car, etc.; or an intangible conceptual
existence, like a project, a process, etc
• An object is represented as a rectangle with two sections −
• The top section contains the name of the object with the name of the
class or package of which it is an instance of. The name takes the
following forms −
– object-name − class-name
– object-name − class-name :: package-name
– class-name − in case of anonymous objects
• The bottom section represents the values of the attributes. It takes the
form attribute-name = value.
• Sometimes objects are represented using rounded rectangles.
• Object Representation
Object Diagram
I Thank You