class Dynamic {
_call($methodName, $parameters) {
/* detect what method name is to be used and get its implementation from a file or a database */
}
}
Tit "Black" Petric wrote:
yeah i know, php5 would benefit greatly from something like this
the problem with php in general is that you cant seperate a class over multiple files (as you must have one file with the class sometimes quite big, over 50kb)
i guess you can split it someways with the implements feature, having a class implementing multiple ones, but its not very dynamic. for a scripting engine the new OOP stuff seems just a bit too static to enjoy.
extending arbitary classes dynamically would be a nice option, but so far its just static, which may proove to be a bit of a problem, since the php dev's think java is the way to go, but java just like any other language needs to be compiled to bytecode only once, php on the fly. why not think more out of the box, like andrei did with aggregate in php4?
it may proove useful, only extending a class with the functions you wish depending on arbitary inputs over http or databases or whatnot, think of a modular system where you only need 1 classname from 5 beeing extended/implemented, having such features would benefit overall execution of the code, since you could "hack" a complete system with only the components you need instead of all of them, in the end splitting class definition and class members in different files, making it easier to write documentation and also helping the overall managebility of the code itself - why search for a function in a 80kb class file when you can select a file only applying to the function scope, and then search that, much smaller file.
in general scope the following is what i learned with php in the last 3 years i've been developing with it:
OOP lacks dynamic patterns - in general it's a step back with what you could do with it, php5's oop support is just laugable. (i mean, what is it with the __constructor() and __destructor()? whats wrong with classname() and ~classname() ? and the different naming conventions? all_i_want() getMeSomeIcecream() - pick one or both, and stick with it) the more code files you use with a project, the more likely it is that your project will preform slowly.. including one huge file is faster than 5 small ones huge files dont do anything for code management, more time you are searching for the function itself, than acctually coding new stuff
sometime you have to decide what do you like better, clean code which is inneficient, or dirty code which is efficient, staying in the middle with the existing OOP syntax takes a lot of work, and you cant please everyone.
personally i preffer clean & efficient, but you really cant win if you have to include every class of a bigger OOP project, instead of just the ones you need to be loaded..
i consider spawning lots of instances of "needed" objects and using them from others et cetera just as bad/good as not using oop at all. you dont use OOP untill you acctually use classes for more than just embedding functions into them.
i hope i make sense?
----- Original Message ----- From: "Marek Kilimajer" <[EMAIL PROTECTED]>
To: "Tit "Black" Petric" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, October 06, 2003 7:36 PM
Subject: Re: [PHP] php5 and possible oop features/questions
Tit "Black" Petric wrote:
will something in the likes of this be possible in php5?
/***/
class some_classname { function some_function(); }
function some_classname::some_function($prefix, $text) { return $prefix.": ".$text."\n"; }
$test = new some_classname; $test->some_function("Output","Hello World!");
This is not necessery in php. As I know C++ has this feature but only so the class definition can be separated from its implementation. Definition goes to a header file so it can be included in other .cpp files in the same project.
Marek
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php