Tuesday, July 14, 2009

PHP: Object Oriented Programming

Object oriented programming concepts were introduced in PHP1.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 as well as impossible to represent real world object in computer world, object oriented programming was introduced. Since then dramatic improvements have been made to OOP.

In object oriented programming inheritance, polymorphism, encapsulation, dynamic binding and exception handling has great value, usage and advantages, 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, you will need to modify all your code, if you haven’t written your code following factory design pattern.
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. Switching from database server won’t bother you at all. You just need to make some small changes in your configuration file.

Revolution of MVC design patterns cause dramatic changes in software development life cycle. Prior to MVC, developers were mixing code all around. It was difficult to figure out where the business code resides and where presentation code is written. Intelligent software engineers, though, were trying hard to separate their business logic from presentation logic; this however wasn’t effective enough for new comers to understand their code and to do necessary maintenance. Without the help of the person behind the project, it’d taken more time to understand the directory structure used.
These draw backs were mostly addressed when MVC design patterns were introduced.

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. From glue I mean it takes data from view and give it to the model, model then process the data and produced desired results. The data, thus obtained, is given to the view. Controller can also be compared to event handlers. It responds to certain events such as posting the data back to server by clicking submitted data.
Hopefully I will unveil some other fact about OOP and design pattern later some time.

14 comments:

  1. my search for an article on php's oop ended here...thanks a lot

    PHP Programming

    ReplyDelete
  2. Nice simple and useful information regarding PHP.

    Web design and development

    ReplyDelete
  3. Boutique Logo Design
    I recently visited the linkage you share here and it's actually a wonderful place for web developer and web developer new bird like me. I find the site very enlightening and worth visiting. I also love the design and the layout it carries.

    ReplyDelete
  4. Its a very nice article. I have share this article to all my friends. Thanks for share this information.

    ReplyDelete
    Replies
    1. This is really a nice post, that you have updated us with all of nice information that can be very useful for future aspect.

      Delete
  5. The information shared was indeed very useful. Thanks for the share.

    ReplyDelete
  6. but no confirm oops program and uses zend

    ReplyDelete
  7. I really like how your class timings of your blog. I enjoyed reading your blog and it is both instructional and interesting. Website Development Bangalore | Web Design Company Bangalore India

    ReplyDelete
  8. If you've never used an object-oriented programming language before, you'll need to learn a few basic concepts before you can begin writing any code. Web Design Bangalore

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Thanks for showing the post about of php development. This post will help me to understand how php will help me to enhance my career in web development.
    Hire Xamarin Mobile app Development Company Texas USA

    ReplyDelete
  11. Hey,
    What a brilliant information you are sharing here about the relevant technology. I really appreciate your effort. I’ll visit your blog again to get some more nice information about other technologies too. Keep up the good work buddy!!
    Hire Reactjs Developers
    Hire Full Stack Developers texas
    Live Streaming SDk

    ReplyDelete
  12. Thanks for sharing this informative article on PHP programming language with a detail introduction and advantages about it. PHP has many framework and Zend is one of them. If you have any requirement to Hire Zend Developers or any PHP web developers for your project. Please visit our website.

    ReplyDelete