|
Posted by Michael Fesser on 08/29/07 09:25
..oO(Jerry Stuckle)
>Not bad. But it also adds complexity and overhead.
Yep, but it pays off for me. I profile my code from time to time and the
real bottlenecks are always somewhere else.
>Don't get me wrong - I like __autoload. But I also like to keep things
>simple. Make for much easier troubleshooting in six months.
Point taken, but for me it has real advantages. My entire framework has
become rather complex and is still growing. I also have to change the
directory structure from time to time to clean things up (there are
still some ugly things left from the early days of that class library,
which have to be improved). So it makes things a lot easier if I can let
the library perform some rather common tasks automatically.
A while ago I also thought about something like an import() function,
which could have worked like the 'import' statement in Java:
import('/path/to/classes/TFoo'); // load a single class
import('/path/to/classes/*'); // load all classes in that directory
But then PHP 5 and __autoload() came up ...
Another interesting approach I once saw (IIRC in the Prado framework,
but I'm not sure) was something like the import() above, but the
function didn't load the classes, but just added the supplied path to
PHP's include_path. Then the class could easily require_once all other
required classes without having to worry about the directory structure.
Micha
Navigation:
[Reply to this message]
|