[ABE.pm] OOP refactoring

Faber J. Fedor faber at linuxnj.com
Tue Jun 27 07:53:59 PDT 2006


If you have been following my saga, you'll remember that I'm writing a
OO Perl report.  The report is made up of a bunch of HTML tables. Each
HTML tables is generated as a separate object.  I ended up doing
something like this in my main program:

    my $reportTable = ReportTable->new();
    $reportTable->date($date);
    $reportTable->style('html');
    $reportTable->printReportHeader();
    
    my $newSectorTable = SectorExposureTable->new();
    $newSectorTable->date($date);
    $newSectorTable->style('html');
    $newSectorTable->debug(0);
    $newSectorTable->fetchData();
    $newSectorTable->printTable();
    
    my $newIndustryTable = IndustryExposureTable->new();
    $newIndustryTable->date($date);
    $newIndustryTable->style('html');
    $newIndustryTable->debug(0);
    $newIndustryTable->fetchData();
    $newIndustryTable->printTable();
    
    $reportTable->printReportFooter();

Note that SectorExposureTable and IndustryExposureTable are subclasses
of ReportTable and execute a ReportTable contructor in their
constructors.

As you can see, I have to set the date for each table.  Why?  When I run
SectorExposureTable->new that calls ReportTable->new which means I have
an empty date field.

Yes, I know, my design sucks which is why I'm refactoring the code.
So I have two questions:

1. How do I get SectorExposureTable to inherit the data I've already set
in ReportTable?

2.  Instead of having my main program call all of these objects, I'm
restructuring the code so ReportTable calls the objects. Do I literally
have ReportTable call the objects or do I cut and paste the code from
SectorExposureTable into ReportTable replacing the SectorExposureTable
object code with ReportTable methods?

While I eagerly await your replies, I'm goingto go muck with the code...

-- 
 
Regards,
 
Faber Fedor
President
Linux New Jersey, Inc.
908-320-0357
800-706-0701

http://www.linuxnj.com





More information about the ABE-pm mailing list