Hello Christopher,

Tuesday, November 25, 2008, 3:27:45 AM, you wrote:

> Hej Marcus,

> I like your approach. It is clear and simple. It would probably solve
> 90% of the cases, where delegation is needed.

> I want to add that a manually defined method should automatically
> overwrite a delegated method of the same name.

> But I also want to bring up two reasonable situations your approach does
> not cover. Your approach does not allow to delegate only a selection of
> methods. This makes sense in order to limit the delegation to known
> functionality. To stick to your example, without selective delegation,
> new methods added to Counter would be automatically delegated to
> CounterUser. This might break things.

> A second situation not covered by your approach is renaming of delegated
> methods. This can be desirable due to name clashes or name changes for
> better understandability.

> Of course there is always the fall back to manually implementing
> delegation. And your approach alone would already be quite useful
> syntactic sugar. But additional syntactic sugar for the two situations
> described above would still be nice :).

> Another thing. I am not sure if you intended that, but I think
> delegation should not force using an Interface definition. Interfaces
> are helpful in combination with type hinting, but for people who prefer
> duck typing, it is reasonable to not explicitly define them. Let's leave
> this choice to the people :).

Your points are all well observed. And yes I limit what my approach can
do in order to Keep It Simple Safe (KISS). While still being able to
manually interfere with/overload the autogenerated code when necessary.
At the same time forcing to delegate to a defined Interface and not
allowing to rename on the fly prevents abusing the functionality and
helps maintainability. On the other hand it forces you to think before
coding as this approach comes with a lack of functionality.

Maybe in a second step we could make the defined interface optional but
with my implementation in mind that might not be the easiest thing to do.

> Best regards

> Christopher




Best regards,
 Marcus


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to