Re: allfiles.php has nothing to do with performance -please read the proposal CAREFULLY
| From: | Matthew Weier O'Phinney | Date: | Tue, 28 Aug 2007 16:04:38 +0000 |
| Subject: | Re: allfiles.php has nothing to do with performance -please read the proposal CAREFULLY | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-47884@lists.php.net to get a copy of this message | ||
On 8/28/07, Philippe Jausions <Philippe.Jausions@11abacus.com> wrote:
> Alexey Borzov wrote:
> > Gregory Beaver wrote:
> > A better solution would be to provide a "one file - one package"
> > distribution or a phar file.
>
> Doesn't sound like a good idea to me. It wouldn't allow developers to
> override one class of the package for bug fixes for instance.
On the other hand, it *would* encourage proper OOP programming:
extension instead of overriding. You typically shouldn't be dropping in
replacement classes, but instead extending the existing class and
overriding methods as necessary.
> > > 2) advanced users who wish to see which files are within a package can
> > > use it to decide which files they wish to include directly
> >
> > They can also do this by a simple
> > var_dump(get_included_files());
> > at the end of the script, why mandate a useless extra file?
>
> Agreed, not needed for the advanced users. An out-of-the-box
> allfiles.php, might be useful to run tests though.
>
> > > It serves no useful performance purpose, and is likely to be slower than
> > > both require_once and __autoload() for complex packages because more
> > > files are loaded.
>
> Indeed.
For packages that implement factories, requiring all files would be
overkill, and __autoload() is a nice solution. However, that said, doing
checks for class_exists() mean more code for the developer over a simple
require/include_once:
if (!class_exists($class)) {
throw new Foo_Exception('Class ' . $class . ' not found by factory');
}
// vs.
include_once $classSpec;
I'd like to see if a simpler mechanism, a one-liner like
include/require_once, could be created.
--
Matthew Weier O'Phinney
mweierophinney@gmail.com
http://weierophinney.net/matthew/