I'm about to embark on a larger project, a customized shopping cart for a client and was thinking it would probably be best to do it using OOP rather than procedural.
I'm just wondering if you agree with me or not. What is the best way to go about this?
OOP vs Procedural
That depends on how familiar you are with OO programming concepts. If you're not (and if you're asking the question you probably aren't) then the answer would depend on whether the client would want to pay to be your guinea pig.
Well, I've done quite a bit of programming in C and Java, so I'm not new to OOP, just haven't used it much with PHP, so I'm not sure about it's limitations. I heard that procedural was faster(execution), but OOP is a lot cleaner and easier to maintain, imo. I suppose the question might be is the longer execution time worth the plusses of doing it as OOP. Probably is.
if there is longer execution time ive never noticed it. not that ive compared OOP code to simular code done in procedural. i do know though that if you where to do it in OOP you would be best to use php5 and php5 has been benchmarked and proven to be faster than php4 in allot of areas.
thorpe wrote:if there is longer execution time ive never noticed it. not that ive compared OOP code to simular code done in procedural. i do know though that if you where to do it in OOP you would be best to use php5 and php5 has been benchmarked and proven to be faster than php4 in allot of areas.
Thanks for the heads up! My host lets me choose between 4 and 5, so I'll make sure to run it in php5. Are there any major differences between php4 and php5 (like certain functions/super_globals that dont work/work differently?)
This is covered in the manual in the section under Migration.
Like thorpe said, the argument about which is faster is pretty specious. If there is a speed difference it's sure to be swamped by other far more significant factors, like the time spent writing and testing.
If you do want to use OO, I'd recommend using PHP 5; its implementation works much more like you'd expect it to (objects are passed by reference instead of value, for example) when compared with how PHP 4 handles it.