I was just wondering whether it would be worth sticking to non-OOP code for the sake of speed. Also, In commercial web-applications, is OOP generally used or avoided? Which is the standard?
Many Thanks,
Ed
Object-oriented programming (OOP) is a way of thinking about and organizing code for maximum reusability. With this type of programming, a program comprises objects that can interact with the user, other objects, or other programs. This makes programs more efficient and easier to understand.
The PHP language itself is not object oriented. The Ruby language is object oriented, so is Java with exception of the primitive types. PHP is a hybrid language capable of objects creation, so is Delphi. There is a big semantic difference between a hybrid language and a object oriented language.
Again, PHP is an example of an object oriented language and we can compare its procedural operations with its OOP implementations of the same functions; taking a mysqli prepared statement, for example.
The standard is to favor readable code over efficiency, because most of the time "more efficient code" runs faster by a single millisecond. Object-oriented programming is generally more readable than a non-object-oriented counterpart.
See also this question: Why are so many web languages interpreted rather than compiled?. The majority of a page's load time is spent sending and receiving data or doing database things.
OOP is generally used in commercial webapps, and is turning to be the standard. The reason for it is not efficiency - it's code re-usability, code readability, easy documentation, structure, and more importantly modularity!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With