Re: PEAR and interfaces
| From: | Gregory Beaver | Date: | Thu, 04 Jan 2007 23:49:10 +0000 |
| Subject: | Re: PEAR and interfaces | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-45427@lists.php.net to get a copy of this message | ||
David Coallier wrote:
> Hey all, sorry if this is repeatitive, and if it is please point me to
> the good documentation but I was wondering if it was ever discussed
> before. The use of interface and it's structure in pear.
>
> Currently what I have done is something like this (package:
> Path_MainPackage)
>
> Path_MainPackage:
>
> Interface:
> --------------------
> interface Path_MainPackage_Interface { }
> --------------------
>
>
> MainPackage class:
> -----------------------
> require_once 'Path/MainPackage/interface/MainPackageInterface.php';
> class Path_MainPackage implements Path_MainPackage_Interface { }
> -----------------------
>
> Let me know if this is the good structure used for PEAR or what shoudl
> be used if it is not.
Hi,
There has been a great deal of debate on how best to do this. I think
that it may be better to require an I prefix. Why? "Interface" can
mean more than just the language construct (think of user interface,
etc.). This means there is actually some unintended ambiguity here. It
is a recognized practice in other languages to simply prepend I, so that
we get:
Path/MainPackage/IWhatItDoes.php
as in
PEAR2/IRegistry.php (PEAR2_IRegistry interface)
or
PhpDocumentor2/Converter/IOutput.php (PhpDocumentor2_Converter_IOutput
interface)
Both of the examples are hypothetical, btw.
I was not in favor of this until I started implementing a few
interfaces, and I have become convinced after using them that this is
far clearer for code organization.
Any discussion is welcome, of course.
Greg