there are areas that need
OO Programming and there are areas suitable for a combination of
Procedural & Functional Programming. Functional & Procedural is fairly easy to implement and it is useful in solving specific problem especially that involves Numerial Computation, System Routines and etc...
for example you just join on the company, and your manager open this problem to you, that they have an
existing system and one of its task is to gather
logs files from the user across the network, before it runs very fast and finish its report within a couple of minutes...you have found out that
increasing of the clients & subdomains makes the system slow. From here you can write a simple
functional programs that help the system pre-processed the file, instead of letting the system scan the entire network as it requires to do some procedures if it is running or not, what you will do is to write a program that sends the file directly to the system (considering it has multiple threads waiting to do the task)
before:
SYSTEM --> SCAN NETWORK --> Client Running ---> Check Finish ---> Check Logs ---> SYSTEM.
now:
Client ---> Finish ---> Send Log to SYSTEM.
on the other hand, OOP is really useful eg.
Polymorphism in object-oriented programming, a ability of one type to appear as ike another type.
Class Square, Class Triangle, Class Circle, Class Rectangle
all of the classes above has a method of
.Area() your problem is to get the area of all shapes that user's created.
so instead of calling:
ObjectSqauare.Area(),
ObjectTriangle.Area(),
ObjectRectangle.Area()
you can do this at the same time. consider this example, written in python.
|
Quote:
class Triangle:
def __init__(self, b, h):
self.base = b
self.height = h
def getArea(self):
return (0.5 * self.base) * self.height
class Square:
def __init__(self, l):
self.length = l
def getArea(self):
return self.length ** 2
class Rectangle:
def __init__(self, w, h):
self.width = w
self.height = h
def getArea(self):
return self.width * self.height
a = Triangle(5,10)
b = Square(10)
c = Rectangle(5,10)
for i in [a,b,c]:
print i.getArea()
|
output of this is:
the code below is not magic:
|
Quote:
for i in [a,b,c]:
print i.Area()
|
even though a, b, and c is totally different shapes, but they have a common method of getting the area. if you were asked to separate 100,000 shapes that having a less than of an area of 50 then you probably know what you will gonna do. This is just one simple topic in OOP, there's a lot more, like combining it with multiple inheritance over Polymorphism, Abstraction, Encapsulation etc... especially in my favorite Decoupling, a practice of using reusable code to prevent rewritting it, and this is only where I can explained, teach, introduce or understand the real meaning of "OVERHEAD"
just imagine all your classes, objects, are loaded into memory, why would you create another one where you have a chance to decoupled that

people keep saying, don't do that, or do this, to avoid overhead... they only saying it because they heard from it, if you asked them what makes it overhead none of them can explained... better go back to functional programming no overhead :-p
have fun learning cheers...