[nycphp-talk] PHP 5 Interfaces
Guilherme Blanco
guilhermeblanco at gmail.com
Tue May 26 16:40:40 EDT 2009
The main purpose of interface is to have a well defined and correctly
implemented fluent interface between 2 code pieces.
If you want to have a particular method as invisible to other classes,
I'd suggest you to create an abstract class that trigger errors on
each protected function. Remember that protected functions when
overloaded can continue as protected OR as public.
Cheers,
On Tue, May 26, 2009 at 5:35 PM, Chris Snyder <chsnyder at gmail.com> wrote:
> On Tue, May 26, 2009 at 4:27 PM, Joseph Crawford <codebowl at gmail.com> wrote:
>> THanks for pointing that out, I guess I am a bit confused as to why they are
>> restricted to public but it answers my question :)
>>
>
> The general idea is that everything behind the interface is a black
> box, so that a class which implements interface foo can be replaced
> with any other class which implements interface foo.
>
> Private methods, being private, are inside of that black box. They
> literally don't matter as far as the interface is concerned, because
> they can not be called from outside the class.
>
> If you're asking, "Why should I use interfaces?" the answer is
> probably only "Because you want to be rigorous and/or satisfy an
> externally imposed requirement that you implement particular
> interfaces." Most PHP projects are going to be to small and too fluid
> to really take advantage of them.
>
> You can get all the benefits of interfaces without actually writing
> them out formally by only relying on well-documented public methods
> and not accessing properties directly.
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
>
--
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9215-8480
MSN: guilhermeblanco at hotmail.com
URL: http://blog.bisna.com
São Paulo - SP/Brazil
More information about the talk
mailing list