Re: PHP 4.0 Bug #5343: a way of implementing class methods
| From: | Stanislav Malyshev | Date: | Sun, 02 Jul 2000 18:23:40 +0000 |
| Subject: | Re: PHP 4.0 Bug #5343: a way of implementing class methods | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-23238@lists.php.net to get a copy of this message | ||
TC>> But say, if I write the class Foo in foo.inc, and I want to add extra methods
TC>> to it, methods I cannot know from the start, it's easier to implement them
This thing is called "inheritance". That's why it exists.
TC>> I was considering the case when I am not the author and the user
TC>> of the class. I may write the class, and leave some hooks for
TC>> the user (say I dunno if s/he will use CSV, Berkeley DB, MySQL
TC>> or Postgres.)
See above.
TC>> Those hooks are ugly if s/he has to extend the class (especially
TC>> if you test the class type), and the only way arround is to
No. You should *never* check class type. Checking class type is a bad
design. You should implement polymorphism via method overriding.
TC>> implement a `stub' and to forward calls to globals functions,
TC>> which can be included separately (written by the user.)
This is yet worse design. I do not see why PHP should support
unwillingness of people to learn how OO works. And no, using keyword
"class" in your program doesn't mean your program is built according to OO
paradigms.
--
Stanislav Malyshev stas@zend.com
+972-3-6139665