Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72280 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41932 invoked from network); 5 Feb 2014 17:27:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2014 17:27:04 -0000 Authentication-Results: pb1.pair.com header.from=rmwscbt@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rmwscbt@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.53 as permitted sender) X-PHP-List-Original-Sender: rmwscbt@gmail.com X-Host-Fingerprint: 209.85.216.53 mail-qa0-f53.google.com Received: from [209.85.216.53] ([209.85.216.53:62018] helo=mail-qa0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/70-38005-66472F25 for ; Wed, 05 Feb 2014 12:27:03 -0500 Received: by mail-qa0-f53.google.com with SMTP id cm18so983213qab.26 for ; Wed, 05 Feb 2014 09:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=QGJbXTYtyzrIn/sT+p67sCtcFDSuvEBPGYpg0u1JQRc=; b=P+vPyJwbjHlDNZFs4ZUUBNJ6Eax5kR/RIXo5o78KZFEHpnT7guI5//JkGQg6JcV2xx S9HrC04XAXaWgAxUQrntNDCw9FOK/iqyCA1kbA6zwdMU2+j7MO1HhR+GGh6vtSZnL9oh cbsRIl8n2TD4Q2UrEvODfOax46FpKI/4E3T+xqkabVIj57KHGsFGwriwQitWoQeT8zkn zHLCbF07ZCLOSAySP1TwVY+UqsB73sgqO6AKR2D0qwfbsXibTElwXWP5RZe7QXxjHZgb iIMXOFN0ajG04fCXRjdfCRqbrSkp7EfcHrAi53LAcLv6UdgMdaNr9qTlMRbCF+6wGEmP z/iA== MIME-Version: 1.0 X-Received: by 10.140.83.112 with SMTP id i103mr4404449qgd.100.1391621220385; Wed, 05 Feb 2014 09:27:00 -0800 (PST) Received: by 10.140.40.146 with HTTP; Wed, 5 Feb 2014 09:27:00 -0800 (PST) In-Reply-To: <52F24BB7.7080802@gmail.com> References: <1391603747.17454.13.camel@guybrush> <52F24BB7.7080802@gmail.com> Date: Wed, 5 Feb 2014 09:27:00 -0800 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c12c6080caff04f1ac108a Subject: Re: [PHP-DEV] Singletons From: rmwscbt@gmail.com (George Wilson) --001a11c12c6080caff04f1ac108a Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable The point (at least in Java) is two fold- one is to separate behavior from implementation to achieve better separation of concerns (I really want to say "swapability", kinda in the flavor of an ObjectFactory). In php this works a little different than Java since php does not have a strong type system so I suppose it does boil down to standardization of methods. 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. I currently use them in my code to standardize some things like some of my Controllers but for the most part I rely more heavily on Abstract Classes. 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). The whole idea here, in my mind, is to gain some of the benefits of multiple inheritance without selling your soul to the devil and wrecking your code. I understand traits get you even closer to that. On Wed, Feb 5, 2014 at 6:33 AM, Rowan Collins wrot= e: > Johannes Schl=FCter wrote (on 05/02/2014): > > On Wed, 2014-02-05 at 13:09 +0100, Sebastian Krebs wrote: >> >>> Beside this: Thats how it works in all me known languages. I don't know >>> any >>> language, where a pattern (in any form) is part of the core. >>> >> You mean like PHP which i.e. ships Observer pattern? >> http://php.net/splobserver >> > > Personally, I've never really understood what the point of those > interfaces is; I guess just for standardisation, which could (now) be > better achieved in a standardisation body like FIG. > > I wonder if anyone actually uses them... > -- > Rowan Collins > [IMSoP] > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a11c12c6080caff04f1ac108a--