![]() |
|
There's more than one way to do things | |
PerlMonks |
OO Design -- Separating Data from Presentationby rkg (Hermit) |
on Dec 13, 2003 at 01:54 UTC ( #314449=perlquestion: print w/replies, xml ) | Need Help?? |
rkg has asked for the wisdom of the Perl Monks concerning the following question:
Hi, all - 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 --
Back to
Seekers of Perl Wisdom
|
|