Object Oriented Programming
 
The Benefits of OOP
 
The birth of object-oriented programming represented a major paradigm shift in development strategy, refocusing attention on an application's data rather than its logic. To put it another way, OOP shifts the focus from a program's procedural events toward the real-life entities it ultimately models. The result is an application that closely resembles the world around us.
 
This section examines three of OOP's foundational concepts:
Encapsulation,
Inheritance,
and
Polymorphism
 
Together, these three ideals form the basis for the most powerful programming model yet devised.
 
Note: For detailed information on OOP please read our C++ tutorial at http://education.ebizelindia.com
 
PHP provides extensive support for developing object-oriented web applications. The area of object oriented programming is, however, large. Entire books can, and indeed have, been dedicated to the subject. As such, a detailed overview of object oriented software development is beyond the scope of this Tutorial.
 
Instead we will introduce the basic concepts involved in object oriented programming and then move on to explaining the concept as it relates to PHP development.
 
An object-oriented programming system (OOPS) consists of objects. The object determines both the state and the behavior of the corresponding element.

Why has object-oriented programming gone from being ``something to think about'' to being a de-facto standard in the way software is developed today? OOA/OOD/OOP is good for: * Analyzing user requirements * Designing software * Constructing software o Reusability (reusable components) o Reliability o Robustness o Extensibility o Maintainability * Reducing large problems to smaller, more manageable problems

 
Why OO PHP5?
 
For now let's just say that OOP is about creating relatively small objects with specific functions that interact with each other to form a complete application.
 
Typically, the main advantages of OOP are:
 
* Reusability of code:
a well designed object has only one specific function and is therefore completely independent of the environment it is placed in and thus can be reused easily.
 
* Clearer structure of code:
Again a well designed object has only one specific function which means that all the code supporting that function is located in one place which increases maintainability.
 
* Easy to maintain:

While using Classes for small projects in your PHP script may seem cumbersome due to extra lines of code that is required, but when you work on a large project or as your project grows in term of size, pages or functionality, using OO approach becomes a necessity.
 
A major disadvantage of OOP is that it requires more lines of code and is therefore more time consuming to produce.
 
In PHP we as developers are left with a choice. Typically, anyone who started out with PHP without any (OO) programming background will have started with learning procedural coding.
 
Most tutorials on the web only cover procedural coding and quite honestly, the old fashioned way is just easier to use in many situations (for instance in small applications, or when you just start out with PHP).