> It's necessary because by calling "bless" you are doing what 
> should have
> been done in the missing object constructor I mentioned 
> above.  You are
> taking the reference and placing it in a different namespace (the
> My::Table::HTML namespace).  Once you've done that, calls to 
> the object will
> search the new namespace for methods, and hence your 
> dostuff() method is discovered.

Is there anything wrong with this (other than calling it a subclass :) ?

> I think someone else mentioned that you are probably not 
> really wanting a
> subclass.  I believe he is correct.

Yep, I used misleading terminology. I'm not really looking for a subclass. 

>  It appears that you 
> could probably be
> working on something like this:
> 
> use My::Table;
> $T = new My::Table;
> # here would be methods to fill the table with data
> $T->title("Test");
> # output the table
> $T->output('HTML');
> 
> # in package My::Table
> 
> sub output {
>       my($self, $format_method) = @_;
>       # this dynamically loads and instantiates the correct formatter
> object.  If you pass in "HTML", you get a 
>       #  My::Table::HTML object, etc.
>       require "My/Table/" . $format_method . ".pm";
>       my $formatter = "My::Table::$format_method"->new();  
> #note that the
> formatter class must have a constructor named
>                                                            #"new"
>       $formatter->dostuff();
> }

I am doing something similar (I'm exec()ing a 'use' instead of require.
Require is probably cleaner).

But what I _can't_ do is "My::Table::$format_method"->new(); because the
object I want to dostuff() with is the existing My::Table object, not a new
object from the sub-package.

> I really recommend you read the perltoot man page for more info on
> subclassing.  It may help clear things up.  OO in Perl is 
> great and powerful
> stuff, but it's not as structured (i.e., _regimented_) as 
> most other OO
> languages, so it's easy to misunderstand what needs to be 
> done.

Believe me, I've reviewed and re-reviewed perltoot, but it just doesn't
cover what I'm trying to do. 

>  In this
> case, however, it appears to be a case of the wrong tool for 
> the job.  A
> subclass is not necessarily what you want.

I'm in agreement here. I just don't know if there's a "proper" OO way to do
what I'm trying to do.


-- 
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;;
 

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

Reply via email to