Wednesday, May 16, 2012

Procedual Programming vs Object Oriented Programming - Part 2

This is a topic every developer must deal with at some point in their life. I broke this article down into several parts. The first part is about procedural programming, the second part is about object oriented programming, and the last part is the summary.

The Pros and Cons I found online were pretty standard for OOP.  There is one that is sort of contradictory.  Many people say it's easier to maintain and you can add or remove functionality faster.  Then they go onto say that it takes more development time to create an OOP application.  How can this be?  Well, it's true in that it takes more development time to get started (both design and creating the structure), but once that base structure has been completed it takes no time at all to add, remove, or alter functionality.

Let's say we have two car factories.  One factory is procedural programming.  They take this car and they add one thing at a time until it can drive off the lot.  It's not exactly fast, but it works.  Now the OOP factory is a new factory and you can't just start building cars.  You have to create an assembly line.  This takes some time and thought as you have to structure it correctly before you can start building cars.  Meanwhile the procedural programming factory has created 10 cars as the OOP factory hasn't even built one.  Once the OOP assembly line is completed; building cars becomes a snap and before you know it has built 20 cars while the procedural programming factory has only built 15.

The other thing I want to go over before I show you my list is that OOP enables you (the developer) to alter functionality with a lot less fear.  By this I mean that since everything is structured and the details are hidden, you don't have to worry about changing a detail that will alter everything else.
Pros
  • Easy to maintain as in you can add, edit, and alter functionality with less fear.  (This is assuming you understand OOP)
  • Reusability.
  • Easier and faster to add additional features.
  • Everything is structured and therefore, code is cleaner looking.  (No more 100+ line procedures)
Cons
  • CPU intensive (Performance may be affected).
  • Learning Curve (Not everyone can wrap their minds around OOP).
  • Harder to follow along as abstraction and inheritance can get confusing.

No comments:

Post a Comment