Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37323 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81905 invoked from network); 30 Apr 2008 04:05:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2008 04:05:42 -0000 Authentication-Results: pb1.pair.com header.from=robert@interjinn.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=robert@interjinn.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain interjinn.com from 66.11.173.122 cause and error) X-PHP-List-Original-Sender: robert@interjinn.com X-Host-Fingerprint: 66.11.173.122 unknown Received: from [66.11.173.122] ([66.11.173.122:55843] helo=interjinn.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/67-28930-510F7184 for ; Wed, 30 Apr 2008 00:05:41 -0400 Received: from [192.168.1.3] (blobule.suds [192.168.1.3]) by interjinn.com (Postfix) with ESMTP id 37F9911FB75; Wed, 30 Apr 2008 00:05:37 -0400 (EDT) To: Nathan Nobbe Cc: RQuadling@googlemail.com, "John Carter -X (johncart - PolicyApp Ltd at Cisco)" , internals@lists.php.net In-Reply-To: <7dd2dc0b0804292051o4fd5e77eu6f8faecad93c378a@mail.gmail.com> References: <48169695.9040803@omegavortex.net> <27A086AB-E111-49C1-ABBD-28FB6E1677BD@procata.com> <48175A65.4070301@zend.com> <1209512914.7057.296.camel@blobule> <10845a340804291714g7eb10362m17af4abecbadf0e4@mail.gmail.com> <7dd2dc0b0804291801m627a7c31h8dd796d7fa1d1257@mail.gmail.com> <1209518549.7057.313.camel@blobule> <7dd2dc0b0804292051o4fd5e77eu6f8faecad93c378a@mail.gmail.com> Content-Type: text/plain Organization: InterJinn Date: Wed, 30 Apr 2008 00:05:38 -0400 Message-ID: <1209528338.7057.349.camel@blobule> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Class Properties in Interfaces? From: robert@interjinn.com (Robert Cummings) On Tue, 2008-04-29 at 23:51 -0400, Nathan Nobbe wrote: > On Tue, Apr 29, 2008 at 9:22 PM, Robert Cummings > wrote: > > > > > That should be a matter of choice for the developer. When you say > "but > > when, down the road, some logic...", all I see is you waving your > hands > > in the air and presuming that the logic will change. The logic may > not > > change, in which case why am I incurring the cost of getter/setter > > methods. "If" the logic changes, I'll be happy to add getter and > setter > > methods at that time and punt the needed functionality into the > magic > > methods which will call the appropriate getter or setter method. You > are > > preparing for a future that may not come, I am willing to > retroactively > > handle that future "if" it arrives. Neither approach strikes me as > being > > more correct but rather they each presume an educated guess on the > > likelihood of the property changing it's semantics down the road. > > > the developer does have a choice. to use an interface, or an abstract > class. data facilitates methods accomplishing what it is they > purport. > quite frankly, i have never written an interface with getters and / or > setters anyway, nor do i see the need to. i would consider it silly. > interfaces are typically used to say, any class that makes this happen > will > likely do it in a way differently than all the others. since, getters > and > setters are almost always implemented the exact same way i find these > topics > to be rather different. if there is in fact a standard way of doing > things > for any given interface, then to realize it, a common implementor > class can > be composed, and delegated to by classes that implement said interface > in > the 'standard' way. Abstract classes and interfaces are not the same. They are used for fundamentally different reasons. An interface is to enforce a contract for all implementations of the interface. Therefore if I were to create an interface with an interface property of x, then all implementations using that interface would know that property x exists and could use it thusly without having to check for it's existence. Using an abstract class is a hack, it's not sufficient for enforcement, and you can't combine multiple abstract classes as you can with interfaces. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP