Re: simple interface standard?
| From: | Jesus M. Castagnetto | Date: | Mon, 30 Aug 2004 21:46:32 +0000 |
| Subject: | Re: simple interface standard? | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-33089@lists.php.net to get a copy of this message | ||
+1 from me on this idea.
--- Greg Beaver <cellog@php.net> wrote:
> Hi,
>
> Would there be an objection to specfying a simple standard for interfaces?
>
> <<BEGIN STANDARD>>
>
> Mypackage.php
> Mypackage/Interface.php
>
> would be a sample structure, so
>
> PEAR.php
> PEAR/Interface.php
>
> would contain the PEAR interfaces.
>
> Interface names would follow the convention that already exists:
>
> interface Mypackage_InterfaceSomething
> {
> }
>
> or,
>
> interface PEAR_InterfaceSomething
> {
> }
As mentioned by others, it might be also good to use:
interface Package_FooInterface
which is closer to what other OOP langs use, (e.g. some Open Source Java
projects use FooInterface and then FooImpl or FooImplementation).
Another way of looking at this is to require that the interfaces names resemble
actions or events, e.g. Foo_Logger, Foo_Bar_Listener, Foo_Bar_Mangler etc. This
will give a better hint on what the implementing class will be able to do.
> <<END STANDARD>>
>
> This way, I could solve all of my concerns about PEAR_Exception with an
> interface like so:
>
> interface PEAR_InterfaceMultiError extends SPL_Iterator
> {
> public function errorCount();
> public function addError(PEAR_Exception $e);
> public function addWarning(...);
> public function iterator functions that allow foreach/while
> }
>
> and then users can do this:
>
> if ($e instanceof PEAR_InterfaceMultiError) {
> foreach ($e as $error) {
> // do stuff
> }
> }
>
> and then count on a consistent API, regardless of how it is actually
> implemented in extended exception classes.
>
> Greg
=====
--
Jesus M. Castagnetto (jcastagnetto@yahoo.com)
Research: http://metallo.scripps.edu/
Weblog: http://weblog.castagnetto.org/
PEAR stuff: http://pear.php.net/user/jmcastagnetto
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush