PHP is mainly a procedural programming language. Procedural programming is so called because the program code gives a set of instructions (i.e. an algorithm) for processing a particular task or set of tasks.

When programming in a procedural manner, the programmer usually breaks down the task/tasks in a top-down manner; this means the program will end up being made of a number of function calls, which can in turn call further functions or tasks.

In procedural programming data is of secondary importance and is normally placed into structures (data structures). As we would expect this data is global to the whole program, allowing us to see and access every function or procedure in the program, each of which will be able to change that data.

This is a very important concept; it means that whenever we change the format of any data structure in our program, all the other procedures and functions that operate on that data will also have to be changed. This can lead us to have to make numerous changes, something we really wouldn’t like to happen when developing software of any type.

For around forty years, the idea of thinking about software in terms of objects surrounds us everyday, and indeed we make use of them almost everyday. For example clicking a button in your text editor to change the font color, wakes up the button object, which in turn tells other objects in the program that it had been clicked and that the font color must be changed. Also when we navigate the channels in our digital boxes to check when a tv programme had started, we may use objects, or better an object-oriented programming software, without knowing it.

The idea of having objects communicating with each other to get, give, and process data is the core concept behind programming in object-oriented manner.

At the end, if you think about it, this is what happens exactly in the real world. Although we cannot say we are objects, we surely can say that we do communicate with each other in order to gain information or give information, and sometimes we use the functions provided by a object to carry out one or more task.

Think for example when we make a phone call. We use the phone object to reach someone who is far away from us.
In OOP happens exactly the same and we may say that software objects simulates the part of real world that concerns an application. This is often called application domain or problem domain.

Most recent versions of PHP have increased their support for object-oriented programming, giving the tools to create objects’ definitions and have them communicate with each other to run tasks for an application.

PHP, being a web scripting language and born as a procedural programming language, doesn’t have all the features of pure object oriented programming languages such as Java and SmallTalk but, still, the possibility to create objects in PHP can bring huge benefits in the form of code design and organization and for the creation of more complex web applications. One of the biggest advantages of OOP versus procedural programming is the ability to promote re-use of code (to improve productivity), as well as being able to adapt methodologies like UML (Unified Modelling Language) and documentors (for PHP is phpdocumentor) to provide API documentation for libraries of classes.

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *