Advantage of Object-Oriented Programming / Why OOPS in PHP?
Object-oriented programming is nothing but a technique to design your application. An application could be any type like it could be a web-based application. OOP is a design concept in object-oriented programming, everything will be around the objects and class.
- OOP in PHP you can create a modular web application.
- OOP in PHP we can perform any activity in the object model structure.
There are many benefits of using oop over the parallel or procedural programming, some of them being:
There are various advantages of using OOP over procedural or parallel programming. The following are some of the basic advantages of using oop techniques.
- Re-Usability of your code: If you will use the OOPs technique for creating your application then it will give you a greater re-usability. For example, if you have created a calculator class in one place then you can use the same calculator class in your application.
- Easy to Maintain: Application develop using oop technique are easier to maintain than normal programming. Again let us take an example of your interest calculator class. Suppose your business need to change the calculation logic. They want to add some charges if your capital is less than 200 USD. Just think about your application is big and developed using normal programming techniques. So first you have to analyze that at how many places we have calculated interest, and then you will change. But just think of the oop technique. You just need to change your method of interest calculation in one place.
- Good Level of Abstraction: Abstraction means making something hidden. By using the oop technique you are abstracting your business logic from implementation. It will provide you greater ease. Again let us take an example of an interest calculator. If you have created a class for interest calculation and your team is going to use that class. Now you are only concern about how interest calculation will be performed because you have created that. Your team member is always have understood that if they will set rate and capital property and apply the interest calculation method then it will return interest.
- Molecularity: If you are creating a separate class for your every problem then you are making it http://modular.So if someone needs to change in the business logic part then he will always go to your business logic code part.
Now if you are clear with the concept of class, object in oop and its advantages. Great!!! Its time to move over the implementation of oop in PHP.