Hi there, am Saturday 19 July 2003 16:30 schrieb Curt Zirzow:
> Sam Baum <[EMAIL PROTECTED]> wrote: >> Hi, >> >> am Friday 18 July 2003 23:08 schrieb Andu: >> >> > This may show my ignorance or my refusal to take for granted something >> > I don't fully understand but I have a hard time figuring out the >> > advantage of using classes as opposed to just functions. I am certainly >> > new to php and at first sight classes seemed to cut a lot of corners >> > but so do functions (with which I have more experience). The more I >> > read about classes the deeper the confusion. Anyone can enlighten me? >> >> Im programming for a few years now in PHP. After trying to use classes i >> dont see their point either. In most cases if i need a class-like >> structure i do something like this: >> >> function thing_new() { >> return ++$GLOBALS['thing_resource']; >> } > > The biggest thing classes do is resolve name space issues, even with > this method you have namespace issues with your function name and your > variables. Sure i have to add and take care of the namespaces myself, but thats it and the amount mental work compared to designing a class is imho lesser in my way. And most times only 1 object of a class gets instanciated, which is to much overhead in an application. And then u dont even need my construct. And if you dont create an object and call the function in an static way (via ::), then the whole benefit of the associated data is gone anyway and the only thing you have is the namespace. So i dont give the Parser the challenge of preparing a class representation and keep it simple. And at last: no more copied objects. > A big downfall with classes, however is there speed. Benchmarking a > function call vs. a class->method call, results in a significant > difference and even more if your using a lot of classes. Ok i just assumed that, but good to know for sure. Sam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php