Wednesday, June 30, 2010

Object Oriented Programming Part 2

In earlier post we have already discovered Object oriented programming, orientation, its fundamentals and features. Here we will take up next remaining questions.

These are the questions whose answer are we seeking here in these blogs…

ü  What is Object Oriented Programming?
ü  What are the fundamental concepts/Features of OOP?
ü  What is Object Based Programming?
ü  What is Procedural programming?
ü  What are the features of Procedural programming?
ü  Compare basic features of the OOP and PP?

First 2 questions have already been answered in the first blog. Here I will start with the third question.

What is Object Based Programming?

Object based programming is associated with objects, objects which consist fields and methods similar to OOP. In object based programming few features(Abstraction, Polymorphism, Encapsulations, Inheritance) of OOP are included. It is not wrong to say, OBP is a subset of OOP where subset has all the features except few.

As I am not concentrating more on this paradigm so I am not going to invest much of your time here.

What is Procedural programming?

In Procedural programming instead of data; structure of the program is the determining feature. Here programmer concentrate on structure of the program instead the behaviour and state of the object.

Edsger Dijkstra's structured programming, where the logic of a program is a structure composed of similar sub-structures in a limited number of ways. This reduces understanding a program to understanding each structure on its own, and in relation to that containing it, a useful separation of concerns.

At low level. structure programming composed of simple, hierarchical program flow structures. These are Sequence(Ordered sequence of statements), selection (Decision making conditions) and repetition(repetitive statements).

In current scenario Fortron, Basic are using structured programming. Branch of structures programming used by Procedural programming which is implemented in C.

Procedural programming is a branch of structural programming where procedure are created on the basis of structures. Procedures are routines, subroutines, functions and their sequence.

What are the features of Procedural programming?

As stated above the poles of the procedural programming are methods, modules, functional calls, variables whereas procedural programming does not have features like abstraction, encapsulation, inheritance and polymorphism.

Methods: These can be understand as the basic feature. We create the structure of the program, divide it into sequence, selection, repetition and accordingly divide one routine to different subroutines and achieve the desired functionality.

Modules: n number of subroutines creates a module where all subroutines are scope specific.

functional calls: As oops uses messages pass between object here it is achieved by functional calls.

Variables: As PP does not belong to object, so each routine has its own variables associated with function’s scope.

Compare basic features of the OOP and PP?

Till now it is understood that Procedure based programming is much closer to deal with structure on the other side OOP only deals with objects, and blueprint of the objects.

Pros and Cons of PP: Procedure based programs tends to run quickly and use system resources efficiently. Whereas the drawback is that it does not fir gracefully with certain type of problems, such as in this paradigm programmer is forced to use structure approach to reach to the conclusion.

Pros and Cons of OOP: OOP is very similar to the perception of world, so it is less difficult to visualize things there. Code reuse is another big advantage of OOPS which is one among the hard hitting drawbacks of PP. OOP is runtime inefficient. It needs more memory and resource to run the program.

If we summarize the whole story, it is evident that none of the paradigm is inferior or superior. It is just our requirements which makes one preferred to us. To finalize the paradigm there are few factors which should be taken into account. First we should look for the data structure of the problem and accordingly should decide the paradigm. Benchmarking is another aspect which effects mostly testing efforts a lot. These 2 factors could highlight the preferences of selecting the programming structure.

I will take a break now. Again I am open to discussions, please post me your queries in comments.

Disclaimer: All the material here is the result of research and understanding of other material. If there is some content which is either incorrect or inappropriate to the context of the article I am always open for discussion.