# An implementation question

**URL:** <https://www.ruby-forum.com/t/an-implementation-question/171864>\
**Category:** Rails\
**Created:** [July 10, 2009, 12:04pm UTC](https://www.ruby-forum.com/t/an-implementation-question/171864 "2009-07-10T12:04:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [July 10, 2009, 12:04pm UTC](https://www.ruby-forum.com/t/an-implementation-question/171864/1 "2009-07-10T12:04:39Z")

</div>

Hi  
This is an implementation question. I have various reports to be  
generated in my application like PDF reports, Excel reports etc So I  
tried like a main class Application report and all the other report  
types its sub classes For example  
TicketExcelreport \< ApplicationReport  
MyPdfreport \< ApplicationReport

Could anybody please point what the pros and cons doing this?

Thanks in advance  
Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [July 10, 2009, 2:29pm UTC](https://www.ruby-forum.com/t/an-implementation-question/171864/2 "2009-07-10T14:29:53Z")

</div>

Am 10.07.2009 um 12:04 schrieb Sijo Kg:

> This is an implementation question. I have various reports to be  
> generated in my application like PDF reports, Excel reports etc So I  
> tried like a main class Application report and all the other report  
> types its sub classes For example  
> TicketExcelreport \< ApplicationReport  
> MyPdfreport \< ApplicationReport
> 
> Could anybody please point what the pros and cons doing this?

As your reports only seem to be different views of the same data, I  
would rather suggest creating #to\_xls, #to\_pdf and so on for Report  
class, rather than subclassing it. If you think the logic invloved is  
too big an instance method, maybe creating a generic PDF::Builder (or  
whatever, that’s shamelessly copied from XML::Builder) would be a  
better idea, that way you could reuse that “pdf building” or “xls  
building” logic elsewehere.

Regards,

Felix
