Re: Singletons
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 <[email protected]>wrote:
> Johannes Schlüter 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
>
>
Thread (13 messages)