rattusillegitimus has asked for the wisdom of the Perl Monks concerning the following question:
Due to recent job search needs in my family, I've been working on a Perl module that will take a resume in XML format and translate it to a variety of formats. I did some looking around the Internet, but none of the wheels I found were quite the right shape or size for my needs, and I thought it'd be a fun learning project. Right now I have a single object with the following output functions:
- output_raw - simply uses the toString method to return the raw XML
- output_html - uses XSLT to transform the XML resume to (X)HTML
- output_text - uses XSLT to transfor the XML resume to reasonably laid out text, then uses Text::Wrap to wrap long lines to 80 columns
- output_pdf - the most ambitious, uses XSLT to transform the XML resume into a series of sections and lines that are then fed to PDFLib to generate a PDF file.
My question is this: should I keep this as a single object, or sub-class each output style into a child object. Ie, something like this:
- Resume - contains the basic functions for importing the XML resume and has an output function that returns the raw XML
- Resume::HTML - child of Resume that overloads the output function with one that transforms the XML to HTML and returns that
- Resume::Text - child of Resume that overloads the output function with one that transforms the XML to ASCII text
- Resume::PDF - contains all of the PDF functions and overloads the output function with one that generates the PDF file
I'm kind of leaning toward this new setup, which I believe leaves me open for future enhancements, but I thought I'd see what the experts have to say. I'd also love to hear any additional features or output formats you think I should add. Once I get more of the code put together, I'll be happy to post it for review.
-rattus
__________
He seemed like such a nice guy to his neighbors /
Kept to himself and never bothered them with favors
- Jefferson Airplane, "Assassin"