What is Object orientated programming?
In object oriented programming is nothing more than the concept of better managements of the codes or scripts you send to the compiler. The main purposes of "Object Oriented Programming" are the followings.
  1. Better manage your codes.
    1. easy to map, and like GPS it helps to keep track of your status.
    2. create replicated version of your codes so that you may have unlimited number of copy of it.
    3. engaging, lining up and freeing up your variables when ever you need.
    4. While function is one-o-one interaction, class works as a template, it can replicate creating object to multiple requests.
  2. Reuse

How it is done or practiced?

Like a manager a class holds the functions and data, and keep it separate form each other. An object is formed from the class by creating an instance of a class. In PHP we use a word "extends".

When we create an object form a class, basically we can inherit the all the functionalities of the class and reuse those functionalities as needed.  Inheritance is the ability of a class that uses all of the functionalities of an existing class, and extend those capabilities for custom use without re-writing the original class again and again.

Did you say Structure? (Click Me)

In programming Structure is ranked one step below the class, A structure contains a different types of data under one heading or name. In programming language C++, structure is  used extensively. Structure (Struct)  is less capable of version of a class, but more efficient in performance wise comparing with its class version. Structure is value type and Class is Reference type, there fore Struct operates directly, without suffering any performance loss. Struct does not create overhead and if you don’t have use inheritance and need to store a small group of data, struct is a better choice over class.

What a class will have for us?

An instance of a class is known as object. When you create a class you are going use the key word "class" and the name of the class. You will come across with the following terms associated with a class.

  1. A class will contain two functions : the constructor and destructor (click me). The constructor is used to initialize or checking on the variables. The constructor is called when we create an instance of a class (class B extends A). The destructors are used when the instance of the class is not needed anymore.
  2. The objects contain both data (known as attributes or properties) and the functions to manipulate the data.
  3. Inheritance: The base class is inherited by the child class. The child class then will be able to inherit and override the attributes and the methods.
  4. Encapsulation: hiding data from the users.
    1. public : data can be accessed by any user of the class.
    2. protected: only the subclass can access the data.
    3. private: is used locally.