Advantage of Object Oriented Programming
- zendnwar
- June 10, 2013
- Advanced PHP(OOP)
- 0 Comments
Re-Usability of your code: If you will use OOP technique for creating your application then it will gives you a greater re-usability. For example, if you have created calculator class at 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 analyse that at how many places we have calculated interest, and then you will change. But just think of oop technique. You just need to change in your method of interest calculation at one place.
Good Level of Abstraction : Abstraction means making something hidden. By using oop technique you are abstracting your business logic from implementation. It will provide you greater ease. Again let us take and example of interest calculator. If you have created 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 understanding that if they will set rate and capital property and apply interest calculation method then it will return interest.
Molecularity : If are are creating separate class for your every problem then you are making it modular.So if someone need to change in the business logic part then he will always go to your business logic code part.
Maintenance : This can become useful is if a particular PHP function becomes outdated and is replaced by a new, similar one. You can quite simply change the code in the one place and you are done.
Use the code over and over : I recently wrote a function to do some minor calculations. Using OOP, I have been able to call upon this function easily and in a well structured manner when needed.
Understanding : When creating classes, I have a clear understanding of where each function is within its given class. There are many tutorials and documents out there that specify the ideal data model. The best way for you to understand your model is to have a clear picture of the functions you need and where they are. The more functions you need and use, the more messy your code is likely to become in a procedural way.
Now if you are clear with concept of class, object in oop and its advantages. Great!!! Its time to move over the implementation of oop in php.