Procedural Programmer or OOP’r?

Further to my last post I would like to quickly talk about coding relative to my recent reading.

When I started out learning php, I taught myself, learnt from reading online and practical uses of code - this for me at least is the primary way I can learn anything. Once you reach functional levels where you can do everything you need to be able to do within your personal mandate then all thats left is refinement.

To this end I have been reading some books on the ideals of programming and a more specific look at things.  I came across this in the process:

Procedural Programming versus OOP
Procedural programming often emphasizes writing code that is as concise as possible and coding directly for the end result. In other words, most procedural programming uses targeted groups of functions that immediately address the problem at hand—usually nothing more, and nothing less. In most situations, this gets you extremely efficient and high-performance applications. One of the downsides to this approach is a lack of maintainability. If the project grows large enough, the developer or developers could end up having to maintain a large number of individual functions, and in some cases, the logic of different functions can become confusingly similar. Object-oriented programming (OOP), on the other hand, emphasizes abstract relationships and a hierarchy of related functionality. Similar functionality can all share a common core, making maintenance much easier. Code reuse is increased as well, as you can easily adapt the abstracted base functionality for new tasks. OOP also can aid in large-scale program design, helping encapsulate and categorize the different sets of functionality required by each part of the system. Such organization and modularity can come at a price, however. If your object-oriented system is poorly designed, it can actually be harder to maintain than any of the alternatives. Often, the extreme modularity and “code-heaviness” of object-oriented designs can suffer from poor performance. Once you get past the problems caused by poor object-oriented design, you will find that creating a system using a custom set of PHP objects, or even a full-blown API, can yield benefits that most every developer will appreciate.

Some times its the simplest things that make u stop and go “oh shit I wish I had read that years ago” - turns out in skipping the book reading part of my php self-tutoring I still managed to run in line with the books, although essentially without bothering with OOP. By nature I realise that I have always coded, since I first began messing about, in a procedural way.

Could it be that Procedural and OOP are equivalent to black and white ends of the hat scale? Often we try and get things done as efficiently and quickly as possible, and frankly I have survived up till a few months ago without ever bothering with Classes in php for a substantial number of my projects - the bigger ones though require some thought out planning if they are to work in the long run.

Seems this week I keep starting posts without remembering what I meant to say?!

Tags: , , , ,
Filed under Reading : Comments (4) : Jun 1st, 2008

4 Responses to “Procedural Programmer or OOP’r?”

  1. 5ubliminal Says:

    Always OOP. During my 9+ years of C++ coding I’ve put together a library of over 50.000 lines (I think it’s over 100k now but I’m not sure and it keeps growing) that can do virtually anything and has a lot of SEO-oriented classes too :). Writing something results based with poor UI but extremely resource intensive is a matter of hours thanks to it.
    Same in PHP. Big library to which I add constantly.

    By working OOP you can put together a lot of pieces of the puzzle which you can use to build anything just applying some glue in between to make it stick.

    I started coding in C (not really OOP) but C++ / classes / virtual methods and so on are god-send.
    Remeber … the library is what separates pros from weekend coders. It’s also easy to share. Look at my eHttpClient class. Many use it but over 90% of them have no idea what goes on behind the scene. And that’s what OOP’s all about.

    Regards.

  2. admin Says:

    your eHttpClient class is damn handy, and Ill admit while I did quickly put my head through it I did just use it out of the bag.

    Just shows I should have spent more time on c++ than I did on counterstrike..lol

    100k lines is a hell of a lot, something for us all to aim for, well the functionality at least :D Thanks for the comment 5ubliminal!

  3. 5ubliminal Says:

    Counterstrike … :) Novalogic’s Joint Operations: Typhoon Rising … and I just reuined your life and gave you an addiction. (gamespot.com to get online). Learning curve: 1month.

    Don’t hate me. This game helps me blow steam off every now and then.

  4. admin Says:

    lol I’m trying to fight them not gain them! inevitably now you have planted that seed though in a months time when I have worked to much and have 5 minutes of weakness I’ll hit download.

    You cant beat a bit of first person shooting to blow away the crap.

    MSN is my latest vice - gotta’ stop booting that crap up!

Leave a Reply