Sunday, February 8, 2015

OOPs I Know it - II

3. Basic Concepts of Object Oriented Programming


  1. Objects
  2. Classes
  3. Data abstraction and encapsulation
  4. Inheritance
  5. Polymorphism
  6. Dynamic binding
  7. Message passing
3.1. Objects - a material thing that can be seen and touched.
Objects are smallest entity of a program. All you name is an object like table, chair or in programs user defined data , vectors, time and lists. When a program is executed, objects interact by sending messages to one another.
Any object can interact with any other object but they should be compatible to send message in type other object understand and similarly receive message 
Example : Student and marks are two objects, in a program student object may send a message to inquire his/her marks in turn marks object will send message by sending marks detail.

3.2.  Classes
Set or category of things, having some property or attribute.
Object contains data and code to manipulate data- so class is collection of objects of similar type.

3.3.  Data abstraction and encapsulation

The wrapping up of data and function into a single unit (called class) is known as encapsulation.
Data is not accessible to the outside world, and only those functions which are wrapped in the class can access it. These functions 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 or information hiding.
Abstraction refers to the act of representing essential features without including the background details or explanation.
Attributes are some time called data members because they hold information. The functions that operate on these data are sometimes called methods or member function.

3.4.  Inheritance
Inheritance is the process by which objects of one class acquired the properties of objects of another classes. It supports the concept of hierarchical classification.
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.

OOPs I know It - I

Disclaimer :
This is an educational material collected from internet, from different blogs/links/materials. Displaying credits is difficult as it was not directly copied from a website and put on this blog, instead it was noted down on paper several years ago and several years later being digitized.

OOP : Object Oriented Programming basic concepts and all one should know

Some History for name sake

POP :Procedure-Oriented Programming

  • Problem is viewed as a sequence of things that needs to be done to achieve any goal.
  • Procedure oriented programming basically consists of writing a list of instructions for the computer to follow, and organizing these instructions into groups known as functions.

Some Characteristics exhibited by procedure-oriented programming are:
  • Emphasis is on doing things (algorithms).
  • Large programs are divided into smaller programs known as functions.
  • Most of the functions share global data.
  • Data move openly around the system from function to function (using global variable).
  • Functions transform data from one form to another.
  • Employs top-down approach in program design

Drawbacks

  • In a multi-function program, many important data items are placed as global so that they may be accessed by all the functions. Global variables are always confusing and prone to change by function accessing it.
  • Another serious drawback with the procedural approach is that we do not model realworld problems very well. This is because functions are action-oriented and do not really corresponding to the element of the problem.

Object Oriented Paradigm 

  • OOP treats data as critical element and does not allow to flow freely around the system.
  • Ties data closely to the function operating it, and protects accidental modifications.
  • OOP allows decomposition of problems into number of smaller entities called "object" and builds data and function around this objects.
  • The data of an object can be accessed only by the function associated with that object. However, function of one object can access the function of other objects. 


Some of the features of object oriented programming are:


  • Emphasis is on data rather than procedure.
  • Programs are divided into what are known as objects.
  • Data structures are designed such that they characterize the objects.
  • Functions that operate on the data of an object are ties together in the data structure.
  • Data is hidden and cannot be accessed by external function.
  • Objects may communicate with each other through function.
  • New data and functions can be easily added whenever necessary.
  • Follows bottom up approach in program design.