Yes! In fact I have done just that, although I didn't call it Formatter. I
like the name Formatter better, thanks for the idea. Currently it's just an
empty namespace, as I don't have any common code (yet) to put in the base
class.

I do call it on the fly by exec()ing 'use $formatter_name'. But my problem
is that the formatter needs to call methods that act on the object, yet I
want these methods to remain in the particular Formatter module that has
been called, not in the My::Table object which I'd like to keep abstract.

-- 
Mark Thomas                    [EMAIL PROTECTED]
Internet Systems Architect     User Technology Associates, Inc.

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;;
 



> -----Original Message-----
> From: Randy W. Sims [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, April 03, 2003 7:05 PM
> To: Thomas, Mark - BLS CTR
> Cc: 'Tobias Hoellrich'; [EMAIL PROTECTED]
> Subject: Re: Perl OO Question: subclass using parent object's 
> methods, not overridden methods?
> 
> 
> On 4/3/2003 4:15 PM, Thomas, Mark - BLS CTR wrote:
> >>Huh? Question is: how do you create your
> >>"My::Table::HTML/ASCII" objects? 
> >>What does the constructor look like?
> > 
> > 
> > I don't. The My::Table::HTML and My::Table::ASCII modules 
> don't have a 
> > constructor. I am using the subclasses to perform operations on the 
> > parent
> > (My::Table) object.
> > 
> > My reason for separating them was to separate the model (My::Table) 
> > from the views. This allows for the creation of a new output (like 
> > My::Table::PDF) without having to change My::Table. Also, 
> I'm treating 
> > those output modules like "plugins" where you only need to 
> install the 
> > ones you care about. So this design may be unconventional, but it 
> > seems to have advantages for me.
> > 
> > So my question boils down to this: Can I override methods 
> that act on 
> > the superclass' object, without having to instantiate a new object?
> > 
> > Maybe my re-blessing "workaround" is really the only way to do it.
> 
> It sounds like your design calls for a "uses" relationship. Store a 
> reference to the correct formatter in your My::Table instance 
> or create 
> one on the fly as needed that refers to the correct 
> formatter. You may 
> want to rearrange the formatters to have a base class if there is any 
> common code between the formatters.
> 
> My::Table::Formatter
> My::Table::Formatter::HTML
> My::Table::Formatter::Text
> etc.
> 
> Randy.
> 
> -- 
> A little learning is a dang'rous thing;
> Drink deep, or taste not the Pierian spring;
> There shallow draughts intoxicate the brain;
> And drinking largely sobers us again.
>                  - Alexander Pope
> 
> 

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to