I have 108 methods that generate custom SQL query strings and then each method query string is executed. These methods are in their own class called “Reports”. Each of these methods take in the same 4 parameters. All 108 methods return different results.
I have a web application that lists all the 108 reports(why I have 108 methods from above) and the user can select which reports they would like to run. I have a database table that has the list of all 108 reports. The table design is Report (ID, ReportName, ReportType, Description). The methods I have created are named after the “ReportName” in the database table.
Method Naming example: Date Gaps -> DateGaps
When the user submits the reports to be ran, a List is created containing the report ID from the Report Table.
I was thinking about creating a method in my “Reports” Class that would have a foreach loop to loop through the list of report IDs and have a switch statement inside to call the report method based on the report ID. This would result in 108 case statements and that seems a little ridiculous.
I feel like this is a bad design from a maintaining standpoint. I also thought about using reflection, but I feel that will be to slow. I have been look at the Strategy pattern, but I am not sure if that is the best approach. My main question is, would a switch statement be acceptable in this case or would a pattern be better?
This might not be a normal question type. Trying to create a discussion for the best design pattern.
Aucun commentaire:
Enregistrer un commentaire