| 
	
 | 
 Posted by Markus Ernst on 09/06/05 12:29 
Chung Leong wrote: 
> Reference is kinda kooky in PHP 4. I always try to dissuade people 
> from using it. 
> 
> In  the book_admin constructor, you need $this->boss =& $boss. 
> Otherwise the object will end up with a copy of its container. 
 
Thank you very much for this comment - this does indeed solve the problems I  
had! 
 
Anyway my goal is improving performance at the front end (implementing PEAR  
Cache did a lot there), and I am not sure if separating the admin functions  
is actually worth the effort. I would highly appreciate some quick comments  
about this: 
 
Existing structure: Class trees based on common base classes, such as: 
 
- class common_functions 
- class entity extends common_functions 
 
- class rubric extends entity 
- class page extends rubric 
 
- class gallery extends entity 
 
- class picture extends entity 
 
Class common_functions contains some methods used for display and lots of  
methods used for administration (such as string formatting, outputting form  
fields and other stuff), and also integrates the database, language and  
configuration objects. 
Class entity controls the dependencies between it's sub-objects. 
Class entity and it's subclasses all have 1 method for retrieving data and 3  
methods for administration (create/update, duplicate, delete). 
 
Thus, also for the front-end scripts all the administration methods are  
loaded. So I thought of 2 possible levels of separation: 
 
1. The admin methods are separated only from class common_functions and  
integrated as a separate object. The $boss reference can be avoided there,  
as those methods do either directly address the database or return values  
instead of setting class properties. But the admin methods of the  
sub-objects will still be loaded by the front-end scripts. 
 
2. The admin methods are separated from all classes and build a separate  
class tree: 
- class entity_admin extends common_functions_admin 
- class rubric extends entity_admin 
and so on; the the main tree subclass constructor tells it's parents which  
admin class has to be loaded. 
 
I implemented solution 2 now and compared the execution times of the most  
time-consuming front-end page (a gallery overview, creates 1 entity, rubric,  
page and gallery object and 28 picture objects for the thumbnails). There is  
no significant difference; it takes between 2.0 and 2.3 seconds[1] (without  
caching of course). On the other side, the admin scripts run slower. 
 
[1] Yes, I have some more ideas where to reduce server load... 
 
So what I would like to know is: Does it make a significant difference if  
only about 200 lines of code are loaded instead of about 1000 lines? Or is a  
possible performance gain compensated by the more complex structure? 
 
 
Now this has got a lot of text - if somebody takes his/her time to give me a  
comment about it: Thanks a lot in advance! 
Markus
 
[Back to original message] 
 |