Re: Multiple Inheritance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greg Donald wrote:
with it, but I will go grab a PEAR module if it fits my needs. Code
re-use may be the only redeeming quality of OO programming, and
honestly I can re-use your code from a non-OO include file just as
easily.

yep, unless the function names happen to conflict with ones you've already written. Then, you run into the oh-crap-I-should-have-planned-to-use-other-code-oh-well-I-guess-I'll-rename-everything-and-waste-hours problem. Class names occasionally conflict, but this tends to be a much smaller and simpler search-and-replace.


Until PHP gets namespaces (translation: never), OO is the only way to do code re-use. Of course, most PHP programmers believe it is faster to write everything from scratch.

More power to them, I'll use [good] code that already exists over my own "brilliant solutions" any day, thank you very much.

I would challenge anyone advocating functions: how many of you have had to modify your function-based program to do a similar thing and been forced to rewrite? Even with well-designed functions, you end up with this problem - code modification is impossible. This is why I hardly ever use static methods or functions. Notice - I do use these things, but you have to know when it is appropriate to do so.

functions and static methods should be used for code that you can guarantee you *don't* want to change - ever (well, at least almost never). Anything that you may need to extend or modify functionality must be implemented with something more flexible, or you're going to get screwed at some point. Static methods should be used for any functions that are re-distributable so that others can plug them in without risk of name conflicts.

If you're writing the code for Yahoo like Rasmus, you're going to write the fastest code imaginable, and you will also be working on the C code to do things.

If you're writing the code for podunk.com, or even for a mid-level traffic site, it is extremely unlikely that you will notice even the slightest difference between OO and non-OO code. The biggest hogs in php programming are:

1) unnecessary images and animated crap/unnecessary javascript
2) terrible database usage
3) too much complexity in the design

It doesn't matter whether you are using OO or functions - if your application has too many lines of code per task, it won't be fast.

Greg

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux