Why use PHP OOP over basic functions and when?

后端 未结 10 1909
深忆病人
深忆病人 2020-12-04 13:14

There are some posts about this matter, but I didn\'t clearly get when to use object-oriented coding and when to use programmatic functions in an include. Somebody also ment

10条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 13:27

    Use of the oop gives you following benefit:

    1. Structuring
    2. Reusability
    3. Easy Maintenance
    4. Encapsulation of the Data

    Coming to the point of making big file with 50 function. You can do that but when it comes to the flow of the function and how the data data will be bind between every function will be a biggest problem.

    Also for the future maintenance if you want to replace the biggest chunk of the flow, trust me you have to go to every function and play around it. Also you never know how your functions are used in other part of the code. So Object Oriented programming is always advisable.

提交回复
热议问题