Re: Class Friendship in PHP
| From: | flaupretre at free dot fr | Date: | Thu, 10 Dec 2015 09:31:46 +0000 |
| Subject: | Re: Class Friendship in PHP | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-89782@lists.php.net to get a copy of this message | ||
Hi Dustin,
----- Mail original -----
> De: "Dustin Wheeler" <mdwheele@ncsu.edu>
>
> In my opinion, class friendship is explicit. I reach for this feature
> when I need to say, "Hey, you two objects; one of you is going to
> know
> more than the rest of my system knows about this other object. I'm
> doing this so that [insert domain-specific modeling concern or
> justification]." In my usage, I don't know that I would use
> friendship
> as a means to make an entire package (namespace, in PHP's case) aware
> of a single object. If I had to model this concern, I would instead
> look to grab some tool that implemented some sort of namespace /
> package visibility.
>
> The other thought I have is that when I go to an object that has
> friended another, I want it to be clear and determined; the degree to
> which I have coupled that object to collaborators through friendship.
> Allowing
friend __NAMESPACE__ allows this to grow somewhat
> unbounded; which... isn't the end-of-the-world by any means and I can
> see where it could be applied. Currently, however, I see it as a
> misapplication of the tool?
>
> Haha, I apologize. I have a hard time finding concision sometimes. I
> guess what I'm saying is that I am definitely not against this idea,
> but that I'm not generally for it, yet. To me, it doesn't map as
> cleanly to the goal of better encapsulation of behaviour in one
> object
> through strategic tighter-coupling to another object. I'd like to
> hear
> more of your thoughts to gain some perspective.
Agreed. It's probably misleading. It was just a way to include the 'package-private'
case, but allowing explicit class names only is probably better, at least for a first RFC.
>
> Would this be something you would consider being a candidate for
> future development and exploration of the feature?
Sure, but I already have a big todo list :).
> > For inheritance rules, you may be interested by a small article I
> > wrote on the subject
> > (http://tekwire.net/joomla/projects/ideas/php-friend).
> >
>
> Yes! You might be delighted to know that the current implementation
> adheres to these rules, exactly. I honestly don't know how I didn't
> come across your article in gathering references. Are you amenable to
> me adding it to my list of references?
Yes, of course.
Thanks for your work. Hope to read your RFC soon.
François