Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72284 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53225 invoked from network); 5 Feb 2014 18:27:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2014 18:27:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.172 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.172 mail-we0-f172.google.com Received: from [74.125.82.172] ([74.125.82.172:40463] helo=mail-we0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 33/C2-38005-78282F25 for ; Wed, 05 Feb 2014 13:27:20 -0500 Received: by mail-we0-f172.google.com with SMTP id p61so586568wes.31 for ; Wed, 05 Feb 2014 10:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=TjxR0AkGheXilU+PusfkUpsxxUObwT8Mpnq2r5HsqEI=; b=f9mvhb8p0C3k5ia1mFQv7a4mLrAbmguNcC5iLUdqdCuYcxzvno1TSYUps+VN8bD92R j6tEFhx8ZYNzpF2hTc921+VbHAfUYAbdxSBUCBsxhrjOdFAfdC8An05hm1LI+lFR5DH0 hr71s1qCfRv1JEQGm470CrYreprxZCAwYKJgMD0WNpd/WvQRGOr/TlcB2deMstAeRejc KmNmgaUzw5vwV1l1e2R4nzJ4i4QdyO6pj9999V33R9fX1WiiHEwkGoo6MHcgEMLsIqHi f2AlCr5qyOFHqPw/D6nsFP49LADnZQ+HEippxmPj5r1WlVeyh/qi1U1eoO12JeMUprGM hT/A== X-Received: by 10.180.91.17 with SMTP id ca17mr18358698wib.41.1391624836994; Wed, 05 Feb 2014 10:27:16 -0800 (PST) Received: from [192.168.0.138] ([62.189.198.114]) by mx.google.com with ESMTPSA id fo6sm48014541wib.7.2014.02.05.10.27.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Feb 2014 10:27:16 -0800 (PST) Message-ID: <52F28282.5020207@gmail.com> Date: Wed, 05 Feb 2014 18:27:14 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: internals@lists.php.net References: <1391603747.17454.13.camel@guybrush> <52F24BB7.7080802@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Singletons From: rowan.collins@gmail.com (Rowan Collins) George Wilson wrote (on 05/02/2014): > The point (at least in Java) is two fold- one is to separate behavior from > implementation to achieve better separation of concerns > [...] > The other (which is really just an application of number one) is using them > to group together different classes under a similar banner (again, in Java > this is really a type issue). You could use this in cases where you do not > want to define an abstract class for instance but still want some > uniformity. This sounds like a good description of why to use Interfaces in general, but doesn't really explain why it is the language's responsibility to define those interfaces for you, rather than some framework. Obviously, there is a benefit to using the same Interfaces in multiple projects, and this is what groups like FIG are working on. A similar role in the Java world might be the various Apache Foundation groups working on interoperable tools, but not contributing to the Sun/Oracle JDK directly. > I know a friend of mine up North is a big fan of traits which from what I > can tell are basically an extension of interfaces (please correct me if I > am wrong- I have not used them). Traits are a slightly different concept, sometimes referred to as "horizontal reuse". They don't create any kind of inheritance relationship between two classes, just allow you to write some code once and use it in several places. Essentially, they are an automated copy-and-paste. [PS: Please reply below, rather than above, other people's posts, preferably trimming the quote to the relevant part as I've done here.] Regards, -- Rowan Collins [IMSoP]