Re: parent_ctor()
| From: | Kristian Köhntopp | Date: | Tue, 18 Jul 2000 16:32:49 +0000 |
| Subject: | Re: parent_ctor() | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-24979@lists.php.net to get a copy of this message | ||
Stanislav Malyshev wrote:
> KK>> a) $a can now actually be a B, and have all slots and methods of B,
> KK>> or
> KK>>
> KK>> b) $a can now poseAs B, but still have the slots and methods of A.
>
> c) Don't use settype(). Settype is bad. You never ever should forcefully
> convert objects between types. That's one of the most horrible features of
> C++.
Of course it does not work in C++, as C++ is statically (compile-time)
typed. settype() is not a problem in dynamically (run-time) typed
languages. Just add the ability to set a "delegate". That's an object
or method to implment a generic mechanism to handle calls to unknown
or unimplemented methods (and/or instance variables) of an object.
> As applied to this situation - forbid settype() on or to any
> non-basic (i.e., not string/number) type. You really don't want it if you
> go for clean OO design.
Agreed, settype() should not be needed in a clean design. It
is useful in purposely unclean designs, though. Specifically,
it is useful in designs where one class must pose as another
class, or any class (the RPC proxy example I keep coming back
to).
Kristian
--
Kristian Köhntopp, NetUSE AG Siemenswall, D-24107 Kiel
Tel: +49 431 386 436 00, Fax: +49 431 386 435 99
Using PHP3? See our web development library at http://phplib.netuse.de/