OOPS (Object Oriented Programming) in my Style

Submitted by leopathu on Sun, 05/08/2022 - 02:56
oops

Download : 

Sample Code

1. Class :

         It is a template definition of the methods and variables (properties) in a particular kind of object

         1.1 Methods :

                 It is similar to function attached to specific classes.

         1.2  Variables

                A symbol of a name that stands for value.

 

2. Object :

         It is a specific instance of a class, it contains real values instead of variables.

 

3. Access Modifiers :

        3.1 Public :

               Default modifier for all variables and methods, open to access everywhere

        3.2 Private :

              Permission to access within the class.

        3.3 Protected :

             Outside members can't access, only availbe within the class and extension of the class.

 

4. Construction :

        It is a method automatically execute while initialize objects with class.

 

5. Inheritance :

        Extend parent class functionality with child class.

 

6. Abstract class and methods :

        We use abstract class when we want to commit the programmer to write certain class methods but we are only sure about the name of the method, and not the details of how it should be written,

         Abstract class can have non abstract methods inside the abstract class.

 

7. Interfaces :

         It is also same as abstract class but has some differents

  •  Only can include abstract methods, constants but can't contain concreate methods and variables.
  •  All the methods must be in the public visibility.
  •  Can implement in more than one class.

 

8. Polymorphism :

        According to the polymorphism principle. methods in different classes that to simpler things should have the same name.

 

9. Type hinting :

        Type hinting forces our functions and methods to get only arguments that belongs to a specific class, interfaces, or an array.

 

10. Static Methods and Properties :

          Access class's methods and properties directly with special resolution (::) operator instead of making as object.

 

11. Final :

         If any methods / variables are declared by the keyword, It cannot be overridden or inherited by another class.

 

12. PHP Class functions :

         1. get_declared_interfaces()

         2. class_exists()

         3. getClass()

         4. getdeclared_classes()

 

13. Autoload :

         Initially search out the class internally and loads its.      

Tags