Re: Re: aggergate vs MI
| From: | (Marcus Börger) | Date: | Tue, 09 Apr 2002 13:39:34 +0000 |
| Subject: | Re: Re: aggergate vs MI | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-82377@lists.php.net to get a copy of this message | ||
At 15:26 09.04.2002, Lauri Liinat wrote:
hi all, I'm personally in favour of having MI in PHP, with the serious alternative being interfaces. I have failed to understand what interfaces would mean in a language such as PHP, though, while I can see the clear hands-on use for MI. 1) the whole concept of interfaces as they are in Java can be thought of as a *subset* of the functionality of MI (when combined with abstract classes), and that being said, it is obvious that everything that can be done with interfaces, can also be done with MI by inheriting from abstract classes (as you would in C++). but with MI you can do even more - you can multiply inherit implementation. so, why cut off possibilities? i agree with Zeev here, MI is definitely superior to interfaces. 2) interfaces lose their meaning in a loosely-typed language such as PHP, which is so dynamic that no attribute nor method declarations are required in order to write code around an object. interfaces are nothing but abstract classes, which do not allow implementation or instantiation. but you do not even have abstract classes in PHP - the compiler doesn't prevent you from trying to call a method that isn't there... the error pops up as late as at runtime. in PHP, object interfaces only exist in the heads of the programmers, not in the compiler, they just aren't there. this way, it doesn't matter if programmers draw interfaces on sand using UML in order to communicate with each other, PHP compiler does not need to know about interfaces. therefore, interfaces really do sound kind of silly in the context of the PHP language. regards, lauritotally correct. but some people here like me want to have some control in the engine that allows detection of missuse of class modells. That is i supply a class package and the user says hey your package does not work and i say hey you missused the package and can present him with the errorlog. marcus