Programming codex



OOP is the acronym derived from object oriented programming, where a program is divided into classes, each classes in turn sub divided in to functions or objects, with providing specific functions. OOPS is a programming principle, which has become very popular in dynamic programming language and is regularly used these days. The typical examples of object oriented programming (OOP) language are C++, J2EE, C#,.Net and Java and that were originally developed for non web solutions. PHP is popularly known for web development since it provides interoperable with several HTTP server interfaces. It also provides database interfaces likes My SQL, Oracle, MS SQL, and Informix. The open source base of PHP enables developers around the globe to add extra and new features in programming.

OOP has so many features like class, functions, object, abstraction, encapsulation, polymorphism, dynamic binding and many more. In fact, most of the modern languages are based on this paradigm. Now, let we consider about constructor and destructor of OOPS. Similar to other OOPS based language; PHP also supports constructor method of classes. Object oriented programming (OOP) has got many specific aspects that are vital in PHP programming.

  1. In PHP, constructor method is called for the creation of every object. In order to run a parent constructor, a call to parent::__construct() from the child constructor is required.
  2. PHP also supports destructor method of classes, for example C++. This feature is very common in PHP 5 and the method is used when the reference of the object is either removed or destroyed. In such case, we will explicitly call parent::__destruct()from the subclass __destruct() method, if the parent class does require any cleanup.
  3. A design pattern is one of the features in PHP programming. Normally it acts like a template and helps the PHP developers to solve a problem. Similarly, polymorphism is the object oriented programming design patterns; we get theinteractions and relationships between classes or objectswith this feature.
  4. The next feature of OOP is ‘name space’ which is introduced by PHP 5.3, and is very common in OOP based language; basically it is a collection of classes, functions and objects. The significance of this feature is that the naming collisions of classes and objects can be avoided.
  5. In lay man language, a class in OOP can be defined as a blue print. It is nothing but a template, where class is considered as noun. For example, let we assume vegetable is a class, where potato, and bitter guard are the objects of this class.
  6. Another benefit of OOP is that each class can generally be kept in its own separate file, and a uniform naming convention is applied, so that it could be easily packed and cataloged within them.
  7. The compact nature of OOP will help the developers in spotting the changes in code easily and thus it completely replaces the long spaghetti code procedural implementation.

As the PHP application grows in size, the use of OOPS concept in PHP would be a boon to the developers, since it reduces the work load when it is implemented properly.


Source by Anoop Kumar

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp

Leave a comment

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



Recent Posts