I was just looking through many books about php e-commerce websites (like Beginning PHP and MySQL E-Commerce) and I realised that so many use object-oriented programming as a basic foundation. I thought about it, and I realised it is perfectly possible to replicate those e-commerce websites without using object-oriented programming, so why do they all go for OOP?
Thanks,
Lucas
Question actually boils down to “Why do most people use OOP?”.
The short answer is because we can 😉
The longer answer is: A good program in a non OOP language still tries to organize itself into sensible chunks that are pretty similar to objects. For example, a C library that takes an opaque data structure as the first parameter of each method. OOP languages have just made it easier to do. (i.e. you don’t need that opaque data, because “this” does the same job.
If you are writing in a language that has all the bells an whistles to organize you code into smaller pieces, you’ll find it much easier to maintain than writing the whole app in one giant main() [I won’t go into the whole why OOP is better]
Any OOP program can be written as non OO – early C++ compilers just converted C++ into C and compiled that – but why would you?