Monday, October 11, 2010

OOP VS POP - From the programmers eye.

"The complexity and efforts made to develop an application remains the same." Maybe I should call this "Law of conservation of Coding".


Let us see what does it mean.

Consider a scenario where an application is developed via POP as well as OOP.

1) The POP scenario:




This was the only choice before OOP. The programmer had to handle all the designing.No inheritance, No Encapsulation, just the simple functions. The efforts for developing the software were solely of coder. The Compiler handles little.

Advantages:
As coder governs major of applications development, there are less chances of bug from complier side. E.G. Chance of bug in compiling assembly language program is less than compiling C program. Thus more control of programmer over software is advantageous. POP is still used in developing small apps (widgets) with languages like Python, C.

Disadvantages:
This approach is certainly not for big applications.



2) OOP scenario

You might have read "Object Oriented" approach was invented to handle increasing complexity. Ever wondered HOW?



Thats how! Shifting it to Complier or Environment(Java).

Compiler now does major tasks, programmer simply mentions "class A extends B" and when object is created, compiler has to
  • Create class object A
  • Create class object B
  • Link these two objects so that elements of B are accessible in A as if they are in same class
  • Take care when a method or variable of B overrides A.
  • Take care of access permissions and check them on every access

U see? The efforts or Complexity is just shifted to complier.

Advantages:
Suitable for big applications.
Its best when compiler is robust(JAVA)

Disadvantages:
What if complier is weak? scroll up to have a look at the large portion that complier has to do. Having to trust complier can be biggest disadvantage.


It is either you or the compiler who has to do some work. Who will it be?

No comments:

Post a Comment