On May 17, 2007, at 3:12 PM, Michael Reece wrote:

> here is a bit of ugliness that hints at what i am after:


I think i do some similar stuff, so I'll give my advice -- which you  
may be better off to not take ;)

I never use 'make manager methods'. i started it as a memory saver  
because i use RDBO in 2 systems with 300+ sql tables/classes in each  
- it was too too much overhead.  instead i use dummy manager classes  
and call get_objects directly.

that being said, since I only call get_objects directly , I found  
that i could improve some memory use if i didn't use the default RDBO  
manager class...  instead I inherit off of my own class which wraps  
the manager calls

if this makes any sense:

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -

package MyApp::RDBO::Object::Item;
# setup here
1;

package MyApp::RDBO::Object::Item::Manager;
use MyApp::RDBO::Object::_ManagerCustom();
use base qw( MyApp::RDBO::Object::_ManagerCustom );
use MyApp::RDBO::Object::Item ();
sub object_class { 'MyApp::RDBO::Object::Item' }
# often no calls
1;

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -

then in MyApp::RDBO::Object::_ManagerCustom I do some wonky things:

a) I have a bunch of standardized calls to get_objects, which just  
subs in this to the query builder: object_class=> $class->object_class
b) i rewrite get_objects , often in this form:

sub get_objects {
        my      ( $self , %kw_args )= @_;

        # mess with kw_args ( often bless into class that provides indexing  
etc )

        my      $results= Rose::DB::Object::Manager::get_objects ( $self , % 
kw_args );

        # mess with results ( often bless into class that provides indexing  
etc )

        return $results;
}

the point of this is as follows:

instead of using helper methods to modify the manger args, just  
inherit from a different class and you can stuff anything you want  
into the manager args,
then just hijack manager calls via your own subclass, which will call  
the real rose manager and return results from it.

this method is slightly slower to run-- there are way more class  
lookups , but it cuts down on enough memory that lets me run more  
processes ( which gets me an overall better server load, as my  
performance  blocking is on the DB , not in perl )


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to