Are you a Programmer?
Are you interested in Programming?
Or are you planning to learn Programming?
Then welcome to the world of OOP (Object Oriented Programming). This is one of the most common term you will strike through while learning programming.

So, what is Object-Oriented Programming (OOP)?

According to E Balaguruswamy in his book,

“OOP is an approach to program organization and development, which attempts to eliminate some of the pitfalls of conventional programming methods by incorporating the best of structured programming features with several new concepts.”

Or

“It is an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand.”

This is not a part of any specific programming languages but a way of developing programs and applications.

Having said that, OOP can be implemented in some of the High Level Programming Languages like C++ & Java; not on all programming language.

Why Object Oriented Programming?

Before OOP, we use to have programming technique called Procedural approach of programming which is now absolute in many cases.

Object oriented paradigm

The main objective of Object Oriented approach is to improve the frequency of programming by eliminating the flaws encountered in the Procedural approach.

OOP treats data as a critical element in the program development and does not allow it to flow freely around the system unlike in Procedural Programming.

Object Oriented Paradigm:

The Paradigm of OOP is simple, to enhance the productivity with less vulnerability. It protects the data by tying it more closely to the functions that operate on it and protects it from unintentional modification by other functions.

OOP allows us to decompose a problem into a number of small entities called Objects and then build data and functions around these entities.

The combination of data and methods make up an Object.

The data of an object can be accessed only by the methods associated with that object. However, the methods of one object can access the methods of other objects.

Let’s see some of the basic features of object-oriented paradigm:

  1. Emphasis on data rather than procedure.
  2. Programs are divided into “Objects”.
  3. Data structure are designed such that they characterize the objects.
  4. Methods that operate on the data of an object are tied together in the data structure.
  5. Data is hidden and cannot be accessed by external functions.
  6. Objects may communicate with each other through methods.
  7. New data and methods can be easily added whenever needed.
  8. Follows bottom-up approach in program design.

Object Oriented Programming is the most recent concept among programming paradigms and means different things to different people.

Here are the Basic Concepts of Object-Oriented Programming with details:

Click on below topics to read them directly.

  • Objects and Classes
  • Data Abstraction and Encapsulation
  • Inheritance
  • Polymorphism
  • Compile and Runtime Mechanisms
  • Dynamic Binding
  • Message Communication
OBJECTS AND CLASSES

                Objects are the basic runtime entities in an object-oriented system. They may represent a person, a place, a bank account or any item that the program may handle.

They may also represent user-defined data types such as vectors and lists. Any programming problem is analyzed in terms of objects and the nature of communication between them.

Program objects should be chosen such that they match closely with the real-world objects. As pointed earlier, an object takes up space in the memory and has an associated address like a record in Pascal, or a structure in C.

OOP

When a program is executed, the objects interact by sending messages to one another. For example, ‘customer’ and ‘account’ are two objects in a banking program, then the customer object may send a message to the account object requesting for the balance.

We just mentioned that objects contain data and code to manipulate that data. The entire set of data and code of an object can be made a user-defined data type using the concept of a Class. A class may be thought of as a ‘data type’ and an object as a ‘variable’ of that data type.

Once a class has been defined, we can create any number of objects belonging to that class.

DATA ABSTRACTION AND ENCAPSULATION

The wrapping up of data and methods into a single unit (called class) is called encapsulation.

Data encapsulation is one of the most powerful feature of a class. 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’s data and the program. This insulation of the data from direct access by the program is called ‘Data Hiding’.encapsulation

Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost, and methods that operates on these attributes.

Encapsulation is one of the three OOP Principles, the other two being Inheritance and Polymorphism.

INHERITANCE

Inheritance is the process by which objects of one class acquire the properties of objects of another class.

It supports the concept of hierarchical classification. In OOP, the concept of inheritance provides the idea of re-usability. This means that we can add additional features to an existing class without modifying it. This is possible by deriving a new class from the existing one. The new class will have the combined features of both the classes.OOP inheritance

Thus the real appeal and power of the inheritance mechanism is that it allows the programmer to reuse a class that is almost, but not exactly, what he wants, and to tailor the class in such a way that it does not introduce any undesirable side effects into the rest of the classes.

POLYMORPHISM

Polymorphism means the ability to take more than one form. For example, an operation may exhibit different behavior in different instances. The behavior depends upon the types of data used in the operation.

For example, consider the operation of addition (+), for two numbers, the operation will generate sum. If the operands are string, then the operation would produce a third string by concatenation.

Polymorphism plays an important role in allowing objects having different internal structures to share the same external interface.

COMPILE TIME & RUN-TIME MECHANISMS

In the context of a programming language, compile time may refer to any of the following:

  • The operations performed by the compiler such as syntactic and semantic analysis
  • The pre-runtime assessment of the program’s behavior

In Java, apart from syntax and semantic checks, one important logical task that is considered to be performed at compile time is the implementation of inheritance. It is at compile time that the child class inherits the public data members and methods of the base class.

Runtime, is the time period when a syntactically correct program is actually executed in the computer system.

Thus, all the tasks that are performed during this time period are prefixed with the word ‘runtime’ or ‘dynamic’, such as runtime type checking or dynamic memory allocation.

DYNAMIC BINDING

Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding means that the code associated with a given procedure call is not known until the time of the 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.

MESSAGE COMMUNICATION

An object-oriented program consists of a set of objects that communicate with each other. Thus, the process of programming in an object-oriented language involves the following basic steps:

  1. Creating classes that define objects and their behavior.
  2. Creating objects from class definitions.
  3. Establishing communication among objects.OOP-Message Communication

Objects communicate with one another by sending and receiving information much the same way as people pass messages to one another.

 

 

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.