![]() |
|
Pathologically Eclectic Rubbish Lister | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
I'm trying to implement a DBI-like module that handles input and output in a generic manner.
I want to be able to take input from a hash, a database, freezethaw, xml, or whatever, then output it using html, xml, text, etc. The method calls would ideally take the following form: or something very similar. (the 'connect' method could be replaced with anything, but it's familiar since DBI's pretty well known) The way I have the object model physically structured is as follows: Obj | +-- Input | | | +-- DB | +-- XML | +-- Hash | +-- etc. | +-- Output | +-- HTML +-- XML +-- etc.Now, the crux of the problem is that I don't want the programmer using this module to have to worry about creating a new Obj::Input::XML object. I want that to be part of the calling syntax, ala Tim. I have the output portion running fine, using the $myObj->set_output( $type ) method. Would it be Kosher to use a $myObj->set_input( $type ) method to hack the symbol table so that $myObj->input points to the appropriate place, or is something like DBI's method relatively easily implementable WITHOUT using XS or anything too fancy? This module is relatively lightweight (outside of its extensive use of object orientation), and I don't want to make it any bigger than necessary. Also, I'm having some trouble deciding when to use inheritance, since it's rather a strange situation. Should MyObj by in MyObj::Input::*'s @ISA, or should the Input::* classes inherit from a generic MyObj::Input class that doesn't inherit from MyObj? I'm rather confused, since MyObj::Input::* is used by MyObj, rather than a subclass of MyObj. Any help to smooth my very confused line of thought would be MUCH appreciated. In reply to Class Hierarchy Design by lattice
|
|