vendredi 2 mars 2018

Multiple report generation. Having a hard time trying to apply SOLID principles

Our system has 6 different reports that users can choose to generate. We can generate anywhere from 1 to 6 reports at the same time for a single client in the system or for multiple clients in a given list.

All 6 reports are different but they have some data that is common to all of them.

Right now each report has it's own query that returns it's own data model. Our process looks something like:

var report1model = ReportService.GenerateReport1Model(clientIds);
var report2model = ReportService.GenerateReport2Model(clientIds);
...

This results in over-querying the db for the same data. If Report1 and 2 both have customer and account information we query the customer and accounts table.

In what ways could I change the code to avoid this code duplication?

So if the use wants to print Report 1 and 2, since they both share the customer and account information. Just query the customer and account information once and generate both reports.

If the user chooses to print Report 3 and 4, which only requeries account information, then just query the account information since neither report requires customer data.

Aucun commentaire:

Enregistrer un commentaire