Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89734 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22642 invoked from network); 8 Dec 2015 04:49:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Dec 2015 04:49:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=mdwheele@ncsu.edu; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=mdwheele@ncsu.edu; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ncsu.edu from 209.85.215.45 cause and error) X-PHP-List-Original-Sender: mdwheele@ncsu.edu X-Host-Fingerprint: 209.85.215.45 mail-lf0-f45.google.com Received: from [209.85.215.45] ([209.85.215.45:33831] helo=mail-lf0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/E2-31749-B3166665 for ; Mon, 07 Dec 2015 23:49:00 -0500 Received: by lffu14 with SMTP id u14so5127226lff.1 for ; Mon, 07 Dec 2015 20:48:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ncsu-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:date:message-id:subject:from:to:content-type; bh=fpk8QS+FS3843102oo3mMjHACWx7ivVnSZot4vLaVgw=; b=M5qWHNhzBsyh85fw4x7dppdUzkoa9iseLCQ9yukhH8gZ2/cJHGqyGQ4IeuZjlZwEo3 jP5NZPDQtIWA/csjcjzBlxNtWAAzOaMpwNggARIb2no0SzfQSh/3hhOuSd+c6EQlA0vz JKwe7Us4074eWiezAsmi4Hmt0P2AQknOsn2RLS8AIB/IiYFt3/JrC/LsKZQiOkhO+nAV VVIv4Ug2R59EJArdqLXP1WgV0xZKh70BkiRovcZHjufnAkiTxjzSEuppKY6ywpF+rqV3 +Qcto3rnt0LvYOdD7WiEXI5bcN7UyDmz9mtEMKL6krI/ZDS3QIlYR1zOpGhg2pLxRjU4 EwzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=fpk8QS+FS3843102oo3mMjHACWx7ivVnSZot4vLaVgw=; b=QmED/aqVyJoXOby6wJPMnIDHVY37aBjOFavmvFTK06rTMtLPm8G7sel/E0SkJXx4Ur GsKk2Dapnbw5JFG1oplH1foHy74G7fPRy705ChL2UkfcNaujK1JAg+tcnTqODrgSdW7D ZQPcE5UgH2Qb7JHHHHOndUQkzH++8zmNvmhpin/OOurhIi8IQ6nEuZ6Q1957mXg1pCoq 3hX4a6BuFnW0Sg/2KrUfxgOTjSo0+X6lziDqfyt086vy/F1rYP7jv9aU0SfRutbtsc5F 4etLCLq8wQMSqjLmJ5gKRmFTy8ZyhNvyWXEgBmayh7w9Rrsu9JG53S64uyEuNqyPm3pU T3HA== X-Gm-Message-State: ALoCoQkmVyQCix8eGY4vavfj9Afk0wqIlVoJj7oK1kKAO6arWyOzxON1gjIen2Hx13ytJiZWGjVQnhcZMUujXK6SfyyW9tVFtPBVFaWCyOJVXmSJr0CftOY= MIME-Version: 1.0 X-Received: by 10.25.151.199 with SMTP id z190mr490476lfd.122.1449550136723; Mon, 07 Dec 2015 20:48:56 -0800 (PST) Received: by 10.112.108.233 with HTTP; Mon, 7 Dec 2015 20:48:56 -0800 (PST) Date: Mon, 7 Dec 2015 23:48:56 -0500 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=001a1140376afbe3c005265bb046 Subject: Re: [PHP-DEV] Class Friendship in PHP From: mdwheele@ncsu.edu (Dustin Wheeler) --001a1140376afbe3c005265bb046 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, Hi, > > My biggest concern about supporting friend classes is the ability to > access non-intentional to be accessed code outside of the original class'= s > knowledge. This by itself is very dangerous. > Just to clarify, the original class explicitly declares friends of itself. There is no opportunity for friend classes to access protected members without the original class knowing about it. It is a specific modeling strategy used to improve encapsulation of behavior at the cost of tight coupling between private collaborators. In addition, other properties of friendship protect the original class from unwarranted access. The common expression of these properties is something like: "Just because I grant you friendship access to me doesn=E2=80=99t automatically grant your kids acces= s to me, doesn=E2=80=99t automatically grant your friends access to me, and doesn=E2= =80=99t automatically grant me access to you." In essense, it is actually a very-safe feature and while it can be abused, surely, I wouldn't go as far to call it very dangerous. I have seen some pretty heinous usage of traits, but I won't condemn the feature as dangerous! :) > I do see however package-private classes as a possibility (I actually hav= e > a partially running patch for that) and allowing it to access protected > (not private) members is a second stage of my goal, so very similar to wh= at > your suggested, with the exception that the original class defined what c= an > be accessed. > > Regards, > I see package-private classes as a separate modeling concern in the same domain of "private collaborators", personally. While package-private classes may be used to implement friend-like behaviors in a programming language, they do not clearly express the core intention of friendship as a tight-coupling between a limited set of collaborators (which may, in fact, be members of separate packages). To be clear, I don't want to pit two features in this domain of private collaborators against one another. I see them as 100% separate modeling concerns; each having its own strengths and wouldn't want to see something as useful as package-private classes be watered down to support friend-like behaviors because it would mean losing expression of the intent: specific targeted coupling of a few collaborators for better separation of concerns. Thanks for your thoughts! --=20 Dustin Wheeler | Software Developer NC State University m: mdwheele@ncsu.edu | w: 5-9786 "If you don't know where you're going, it's easy to iteratively not get there." --001a1140376afbe3c005265bb046--