On 11/12/05 10:04 PM, Mark D. Anderson wrote:
>> The problem is, how do I know to clone the base class metadata?  In nearly
>> all cases, this is not done.  As far as I can see, there's no way for RDBO to
>> know when it should be done without being told in some way by the developer.
> 
> There must be something basic I'm missing. If I say:
> 
>      package Book;
>      use base 'Product';
> 
> then what else could I mean?

If you take a look at the RDBO tutorial in CVS, it'll probably start to make
more sense.  I'll try to summarize: Rose::DB::Object is designed as a base
class, but the recommended "best practice" it to make your own base class
that inherits from Rose::DB::Object and then build your "real" classes on
top of that.

This is done to give you a single place to add your customizations.  In
particular, specifying the default database connection, convention manager,
metadata class, and other pieces of class data.

So, a an example hierarchy looks like this:

 Rose::DB::Object -> My::DB::Object -> Product -> Book -> TextBook
                  A                 B          C       D

Rose::DB::Object and My::DB::Object are abstract and have no table or column
metadata.  Book and TextBook do have metadata, and Product might (depending
on whether or not generic "products" exist).  So, in inheritance step A and
B there is no cloning of the metadata object, in C there might be a clone,
and in D there is definitely a clone.

There's no obvious way for the framework to know when to clone and when not
to clone.  Only the developer creating this object hierarchy has that
information.  At best, there could be a heuristic that says "clone when > N
levels of inheritance from Rose::DB::Object, but that's pretty sketchy.

I guess another alternative is to always clone, guessing that cloning a
(relatively) "empty" metadata object from an abstract base class isn't
really harmful.  But I worry about situations where a class shares no column
or table metadata with its base class, and then has to remember to blank out
all that data from its cloned meta object before adding its own.

I dunno, maybe that's not a big deal either.  I'll shake all this out when I
start to write the inheritance tests, I guess.  Right now, I have a lot of
bug fixes and several new features queued up in CVS, plus the eternally
absent tutorial still in progress, so there'll be at least one (relatively
big) release before I tackle inheritance.

-John




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to