Re: PHP 4.0 Bug #5343: a way of implementing class methods
| From: | Teodor Cimpoesu | Date: | Sun, 02 Jul 2000 16:49:19 +0000 |
| Subject: | Re: PHP 4.0 Bug #5343: a way of implementing class methods | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-23226@lists.php.net to get a copy of this message | ||
Hi Stanislav!
On Sun, 02 Jul 2000, Stanislav Malyshev wrote:
> w>> I?d welcome this kind of functionality.
> w>> It?s sometimes needed to equip classes with some standard methods and
> w>> making class X a subclass of Y of Z of A of B is not the fine way ;)
>
> Why you need this? PHP is not a compiled language, so I don't see why you
> need to have 2 files for a class. For C++ this makes sense, since you
> usually get class as a library, so you can't use it as class definition,
> you need source interface definition - .h. But I do not see cause for this
> in PHP.
But say, if I write the class Foo in foo.inc, and I want to add extra methods
to it, methods I cannot know from the start, it's easier to implement them
separately, rather than extending the class, and adding the new methods.
I was considering the case when I am not the author and the user of the class.
I may write the class, and leave some hooks for the user (say I dunno if s/he
will use CSV, Berkeley DB, MySQL or Postgres.)
Those hooks are ugly if s/he has to extend the class (especially if you test
the class type), and the only way arround is to implement a `stub' and to forward
calls to globals functions, which can be included separately (written by the user.)
-- teodor