rkg has asked for the wisdom of the Perl Monks concerning the following question:
A basic OO question involving separating data from presentation:
I am trying to work out an object hierarchy for a reporting system. I am envisioning a base Report class which is subclassed into various forms of displaying the report, such as HTMLReport, PDFReport, ExcelReport, etc.
I'll have several report objects -- RevenueReport, ReceivablesReport, etc which will take parameters on creation indicating geography, time period, etc.
Here's my question: how do I tell a report (say, an instance of RevenueReport) to render as, for example, an HTMLReport? Creating all the combinations explicitly (RevenueHTMLReport, RevenueExcelReport, etc) is clear code-stink.
On the other hand, passing the render type into the report my $report = SalesReport->new(%args, type=>'HTMLReport') and then making this SalesReport an HTMLReport by pushing 'HTMLReport' onto its ISA array seems even worse.
So I want to separate data from presentation...
so what is the correct way to tell my data object how it should present itself?
Many thanks for clarifying this for me --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OO Design -- Separating Data from Presentation
by adrianh (Chancellor) on Dec 13, 2003 at 02:26 UTC | |
by rkg (Hermit) on Dec 14, 2003 at 01:33 UTC | |
|
Re: OO Design -- Separating Data from Presentation
by pg (Canon) on Dec 13, 2003 at 02:33 UTC | |
by dragonchild (Archbishop) on Dec 13, 2003 at 05:19 UTC | |
by xenchu (Friar) on Dec 13, 2003 at 02:54 UTC |