Академический Документы
Профессиональный Документы
Культура Документы
Introduction to OOPs
1. Procedure oriented programming approach.
Main Program
Function-4 Function-5
Local variables have limited use. It is very difficult to keep track of which
function has changed the values of which variables. Another problem with this
approach is that if we need to add any new data to the program, all the functions
which access the data should be modified. This may provide room for errors to creep
in.
1. Class and Object: A Class represents a set of objects that shares common
characteristics and behavior or A Class is an overall organization of data and
operational method.
An object is a real world entity / real world identifiable entity which represent
characteristics, state and behavior. In other words, Object is a variable of type
class or object is an instance, which represents the characteristics of a class.
e.g. Vehicle is a class, Car is an object.
Furniture is a class, table is an object.
2. Data abstraction: Abstraction refers to the act of representing essential features
without including the background details / explanation. Abstraction is the concept
of simplifying a real world concept into its essential elements.
e.g. To define an abstract STACK class using abstract representation:
Class : STACK
Data : St [20], top
Methods : 1. Pre-Condition: isEmpty (), isFull ()
2. Functions: PUSH (), POP ()
Abstract class represents only the external structure of the class but not the
internal structure.
3. Data Encapsulation and hiding: The wrapping up of data and method into a single
unit is known as Encapsulation. The data is not accessible to the outside world and
only those methods, which are wrapped in the class, can access it. These
methods provide the interface between the object data and the program.
This insulation of the data from direct access by the program is called Data
hiding.
Encapsulation is a way to implement data abstraction. Encapsulation hides the
details of the implementation of an object.
4. Polymorphism: Polymorphism means the ability to take more than one form. An
operation may exhibit different behavior in different instance. The behavior
depends upon the type of data used in the operation. A function name can be
used to handle different types of arguments. This is similar to a particular word
having different meanings depending on the context. Polymorphism is extensively
used in implementing inheritance.
5. Inheritance: Inheritance is the process by which objects of one class acquire the
properties of object of another class. In OOP, the concept of inheritance provides
the idea of reusability. This means that we can add additional features to an
existing class without modifying it. This is possible by deriving a new class form
the existing one. The new class will have the combined features of both the
classes. It represents parent–child relationship or hierarchical model.
Message passing involves specifying the name of the object, name of the
method and the information to be sent.
7. Dynamic Binding: Binding refers to the linking of a procedure call to the code to
be executed in response to the call. The dynamic binding means, the code
associated with a given procedure call is not known until the time of call at runtime. It is
associated with polymorphism and inheritance. A procedure call associated with a
polymorphic reference depends on the dynamic type of that reference.
8. Bottom-up approach: OOPs follows the bottom-up approach for coding and top-
down approach for design. It reduces the compilation time and debugging time.
Bottom-up approach follows the user to develop a unit module first, then
integrates all unit module into a single main module.
Example for OOPs languages are C++, JAVA, Visual Basic, Visual C++ etc.,
Disadvantages
It does not have functional abstraction.
There is still a lot of discussion about which features are really essential to
Object-Orientedness.
Lack of solid formal foundations.
Review Questions