PRICIPLES OF OBJECT ORIENTED PROGRAMMING

Procedure oriented programming:-

Conventional programming using high-level languages such as COBOL,FORTRAN and C is commonly known as procedure-oriented approach the problem is analysed as a sequence of things to be done such as reading, calculating and printing. A number of functions are written to accomplish these tasks. The primary focus is on function.
 procedure-oriented approach basically consists of writing a list of instructions for the computer to follow and organise these instructions into groups known as functions. we normally use a flowchart to organise these actions(Functions) and represents the flow of control from one action to another action.
                                                                      In a multi-function program, many data items are placed as a global, so that they may be accessed by all the Functions. Each functions have its own global data. Handling  of global data is more difficult in a multi-function program. This provides an opportunity for bugs to creep in.
Procedure-oriented approach does not suitable to design the real world problems. The some of the characteristics of Procedure Oriented programming language are emphasis(focus or importance) is on doing things.
Large programs are divided into the small programs known as functions
Most of the functions share global data
Data move freely around the system from function to function. It follows top-down programming approach.

Object oriented programming paradigm or approach:-

OOPS treats data as an important element in the program development and doesn't allow it to flow around the system. It combines data more closely to the functions that operate on it and protects it from outside functions. oops allows to divide a large program into number of entities called objects And then bills design data and functions around these objects the data of an object can be accessed only by the functions associated with that object.

Features of oops:-

  • Emphasis is on data rather than procedure
  •  programs are divided into entities that are known as objects
  • Data Structures for design such that they characterize the object
  • Functions that operates on the data of an object are tied or bind or combine or wrap together in the data structure data is hidden and cannot be accessed by external functions.
  • Objects may communicate with each other through functions.
  • New data and functions can be added easily whenever necessary it follows bottom up approach in the program design.

Basic concepts of oops:-

oop has the following basic concepts
  • object
  • class
  • Data abstraction
  • Data encapsulation
  • polymorphism
  • Inheritance
  • Dynamic Binding
  • Message passing

object:-

objects are basic run-time entities in an object-oriented programming system. they may represent a place, person, table of data, Bank account or an item used in the program

Sometimes we can represent user-defined data types like vectors and list
The following diagram shows the Object Notation in object-oriented analysis and design.

Class:-

A Class is a user-defined data type. It is used to define objects and member functions in a single unit.
Once the class is defined, it behaves as a data type by using this data type.
We can create variables, these variables are also known as objects.
Each object is associated with the data type of class from which they are created.
Thus a class is collection of objects.
eg:- mango, apple and orange are the members of class fruit.

Data abstraction:-

Abstraction refers to the act of representing the things without including the background details or explanations.
Classes use of concept of abstraction and or defined as a list of abstract attributes such as sno, sname, group etc., and methods that operates on the attributes(data items).

Data encapsulation:-

The wrapping up of data and functions into a single unit is known as encapsulation.
It is the most useful feature of class. The data is not accessible to the outside world and only these methods which are wrapped in the class can access it.These methods Provides an interface between object data and the program. This insulation of data from Direct Access by the program is called Data Hiding.

polymorphism:-

polymorphism is another important concept of oop. polymorphism is a combination of 2 greek words "poly" or "morphism". Here poly means many and morphism means forms.
polymorphism is defined as the ability to take more than one form polymorphism can be applied on functions, then it is called as function overloading. If we apply on the operators then it is called as Operator Overloading.
eg:- 10+5=35
good+morining=good morning

polymorphism is of 2 types
1.  compile time polymorphism
2. run-time polymorphism

Complie time polymorphism:-

 If the function call links with the function body during compile time then it is called as compile time polymorphism.

Runtime polymorphism:-

if the function call links with the function body at runtime then it is called as runtime polymorphism.

Inheritance:-

Inheritance is the process of gaining properties of one class into the another class. The class from which we are getting the properties is known as base class or superclass or parent class. the class which receives the properties from the existing class is known as derived class or subclass or child class.
                                                           In OOP , the concept of inheritance provides the idea of reusability. This means that we can add new features of the existing class without modifying it. They are several types of inheritance.
  1. single inheritance.
  2. multiple inheritance.
  3. multilevel inheritance.
  4. hierarchical inheritance.
  5. hybrid inheritance.
  6. multipath inheritance.

1. single inheritance:-

the process of deriving only one subclass from the superclass is known as single inheritance.

2. Multiple inheritance:-


The process of deriving one subclass from more than one superclass is called as multiple inheritance.

Multi-level Inheritance:-

The process of creating one subclass from another subclass is called as multi-level inheritance.


4.Hierarchical inheritance:-

The process of creating more than one subclass from single superclass is called as hierarchical inheritance.

5.Hybrid Inheritance:-

If we combine two or more above inheritances then it is called as Hybrid Inheritance.


6.Multi-path Inheritance:-

If we gain properties of one class into another in multiple paths then it is called as multi-path inheritance.


7.Dynamic Binding:-

Binding refers to the linking of procedure call to procedure body to be executed in response to procedure call. Dynamic binding means that the code associated with the procedure call is not known until run time of the program.

8. Message Passing:-

An object-oriented program consists of a set of objects that communicate with each other.
the process of programming is an  object oriented language involves the following steps:-
  • Creating classes- that define objects & their beaviour.
  • creating objects- from class definitions.
  • Establishing the communication between the objects.
objects communicate with one another by sending & receiving information through functions. A message for an object is a request for execution of a procedure and therefore invoke a function in the recieving object that generates the desired result.
message passing involves the name of the object, name of the function & information to be sent.
eg;-

      employee.getsalary(ecode);

In the above example employee stands for 'object name' & getdalary represents 'function name' ecode represents information to be shared.

objects have lifecycle. they can e created & destroyed. communication with an object is possible as long as it is alive.




Comments

Popular Posts