Archive for the ‘Reading’ Category

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