Object Oriented Concepts
Object Oriented Concepts
Contents
1. OBJECT ORIENTED CONCEPTS ........................................................................................................... 1
OBJECT ......................................................................................................................................................... 1
CLASS ........................................................................................................................................................... 1
CLASS vs OBJECT ....................................................................................................................................... 1
WHAT IS OBJECT ORIENTED? ................................................................................................................. 2
OBJECT ORIENTED METHODOLOGY .................................................................................................... 2
ADVANTAGES OF OBJECT ORIENTED METHODOLOGY .................................................................. 3
OBJECT ORIENTED CONCEPTS ............................................................................................................... 4
DIFFERENCE BETWEEN ABSTRACTION AND ENCAPSULATION ................................................... 7
OBJECT
Objects are the physical and conceptual things that exist in the universe.
In programming terms, an object is a self-contained component that contains properties and methods
needed to make a certain type of data useful.
Object is an instance of a class.
CLASS
A class is a blueprint or template or set of instructions to build a specific type of object.
In programming terms, a class is a way to bind, data and functions into a single unit.
A class is an abstraction that describes important properties of object.
CLASS vs OBJECT
Parameters CLASS OBJECT
Definition Class is mechanism of binding data Instance of class or variable of class.
members and associated methods in a
single unit.
Existence It is logical existence It is physical existence
Memory space is not allocated, when it Memory space is allocated, when it is
Memory Allocation
is created. created.
Declaration/definition Definition is created once. It is created many time as you require.
IDENTITY
Identity means that data is organized into discrete distinguishable entities called objects.
Objects can be physical or conceptual.
In real world object simply exist whereas in programming language each object has a unique
handle (unique identifier) by which it can be uniquely referenced.
The handle can be implemented by address, array index or unique value of an attribute.
CLASSIFICATION
It means that objects with same data structure (attribute) and behaviour (operations) are
grouped into a class.
A class is an abstraction that describes important properties and ignores the rest.
POLYMORPHISM
It means that the same operation (action or transformation that the object performs) may behave
differently on different classes.
Specific implementation of an operation by a certain class is called a method.
INHERITANCE
It is the sharing of attributes and operations among classes based on a hierarchical relationship.
Subclasses can be formed from broadly defined class.
Each subclass incorporates or inherit all the properties of its super class and add its own unique
properties.
ANALYSIS
An analysis model is a concise, precise abstraction of what the desired system must
do, not how it will be done. It should not contain any implementation details. The
objects in the model should be application domain concepts and not the computer
implementation concepts.
SYSTEM DESIGN
The designer makes high level decisions about the overall architecture. In system
design, the target system is organized as various subsystems based on both the analysis
structure and the proposed architecture.
OBJECT DESIGN
The designer builds a design model based on the analysis model but containing
implementation details. The focus of object design is the data structures and algorithms
needed to implement each cycle.
The Objects identified in the system design phase are designed. Here the
implementation of these objects is decided in the form of data structures required and
the interrelationships between the objects.
IMPLEMENTATION
The object classes and relationships developed during object design are finally
translated into a particular object oriented programming language, database, or
hardware implementation.
During implementation, it is important to follow good software engineering practice
so that the system can remain the traceability, flexibility and extensibility.
ADVANTAGES OF OBJECT ORIENTED METHODOLOGY
• The systems designed using OOM are closer to the real world as the real world functioning of the
system is directly mapped into the system designed using OOM. Because of this, it becomes easier to
produce and understand designs.
• The objects in the system are immune to requirement changes because of data hiding and encapsulation
features of object-orientation.
• OOM designs encourage more reusability. The classes once defined can easily be used by other
applications. This is achieved by defining classes and putting them into a library of classes where all
the classes are maintained for future use. Whenever a new class is needed the programmer first looks
into the library of classes and if it is available, it can be used as it is or with some modification. This
reduces the development cost & time and increases quality.
• Another way of reusability is provided by the inheritance feature of the object-orientation. The concept
of inheritance allows the programmer to use the existing classes in new applications i.e. by making
small additions to the existing classes can quickly create new classes.
• As the programmer has to spend less time and effort so he can utilize saved time (due to the reusability
feature of the OOM) in concentrating on other aspects of the system.
PREPARED BY: PRAMOD MATHEW JACOB 3
OBJECT ORIENTED CONCEPTS
Inheritance is the capability of one class to acquire properties and characteristics from another
class.
The class whose properties are inherited by other class is called the Parent or Base or Super
class. And, the class which inherits properties of other class is called Child or Derived or Sub
class.
Inheritance makes the code reusable. When we inherit an existing class, all its methods and fields
become available in the new class, hence code is reused.
All members of a class except Private, are inherited
Purpose of Inheritance
1. Code Reusability
2. Method Overriding (Hence, Runtime Polymorphism.)
3. Use of Virtual Keyword
1. Single Inheritance
2. Multiple Inheritance
3. Hierarchical Inheritance
4. Multilevel Inheritance
5. Hybrid Inheritance (also known as Virtual Inheritance)
Single Inheritance
In this type of inheritance one derived class inherits from only one base class. It is the simplest form of
Inheritance.
Multiple Inheritance
In this type of inheritance a single derived class may inherit from two or more than two base classes.
Hierarchical Inheritance
In this type of inheritance, multiple derived classes inherits from a single base class.
Multilevel Inheritance
In this type of inheritance the derived class inherits from a class, which in turn inherits from some other
class. The Super class for one, is sub class for the other.
Abstraction Encapsulation
1. Abstraction solves the problem in the 1. Encapsulation solves the problem in the
design level. implementation level.
2. Abstraction is used for hiding the unwanted 2. Encapsulation means hiding the code and
data and giving relevant data. data into a single unit to protect the data from
outside world.
3. Abstraction lets you focus on what the 3. Encapsulation means hiding the internal
object does instead of how it does it details or mechanics of how an object does
something.
4. Abstraction- Outer layout, used in terms of 4. Encapsulation- Inner layout, used in terms
design. of implementation.
For Example:- For Example:-
Outer Look of a Mobile Phone, like it has a Inner Implementation detail of a Mobile
display screen and keypad buttons to dial a Phone, how keypad button and Display Screen
number. are connect with each other using circuits.