[CDBI] Different subclasses for one table / Factory Pattern?
perrin at elem.com
Thu Aug 3 21:59:27 BST 2006
On Thu, 2006-08-03 at 22:31 +0200, Stephan Brunner wrote:
> Right now, I'm thinking about giving up my subclasses in favour of a method
> File->type() that tells me what kind of file I'm dealing with.
We've done that before too, and used Params::Validate to enforce the
right args to create() for each type.
> I dislike the
> idea because I'll have methods in package File that are invalid for certain
> objects (for objects of wrong ->type()).
You might consider having that object delegate all the file-related
methods to another class, which it could choose based on the type.
There are some delegation/proxy modules on CPAN. That won't work for
column accessors though. You could verify them too, but at some point
it's just too messy.
More information about the ClassDBI