PHP: Object Oriented Programming

26 May

Object oriented programming concepts were introduced in PHP version 1.4, I guess.

How many people around you play with object oriented programming?

If not working in any kind of MVC frameworks, I guess very short number of people.

Developers are often used to structured programming and don’t bother themselves learning object oriented programming concepts and paradigm.

Well, when software engineers realized that it’d become very difficult to manage and maintain thousand lines of code, object oriented programming was introduced. Since then dramatic improvements have been done to OOP.

In object oriented programming inheritance, polymorphism, encapsulation, dynamic binding and exception handling has great usage and advantage, however class and objects are the most basic concept.

Class is blue print containing properties and method associated with same entity. Object is the instance of the class and is used to access properties and method of the class.

In addition to OOP, design pattern make jobs easier for the programmers.

Singleton, factory and specially MVC design patterns are very useful these days.

In singleton design pattern one object of the class exist throughout the life cycle of the software application. If programmer tries to instantiate another object of the same class, a reference to the object instantiated earlier, is granted.

A class implementing factory design pattern works as bridge between multiple classes. Consider an example of using multiple database servers like SQL Server and Oracle. If you are developing an application using SQL Server database as backend, but in future need to change backend database to oracle. Without using factory design pattern, you will need to modify all your code.

In factory design pattern you need to do very little work to achieve this. A class implementing factory design pattern takes care for you and lessen your burden.

In MVC design pattern M stands for Model. Model contains your application’s business logic.

V stands for View. It’s the presentation layer.

While C stands for controller that work as glue between view and model.


2 Responses to “PHP: Object Oriented Programming”

  1. Anitha June 19, 2009 at 5:04 am #


  2. Rain Wilber July 25, 2009 at 3:15 pm #

    Thank you, Faheem, for this briefing of what object oriented programming means in general. Your probably a very busy person, but it would be great if you could continue adding to this great subject, people need to be eating it up these days!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: