Basically I am forced to use a path url as follows GET /accounts/<accountNumber::string>/reports?type=<DAILY>&date=<YYYY-MM-DD>
The thing is that my behaviour is highly dependent of my report type, as you can see "Daily" in my example. So i am looking for a design pattern that would allow me to simulate a controller factory that would instantiate specific controllers for each of my reports types. For example i would have a DefaultController having a method called getReport that would be mapped to my GET request and that would delegate to other specific controllers (i.e: DailyReportController) the task of generating and returning the report.
I want my design to be as reliant as possible to on the SOLID principles and other clean code and maintainability principles. So even if i would add a report type in a month, all it would take me is adding a new TypeReportController and a value in my ReportType enum, and not having infinite methods in my controller and my services
Aucun commentaire:
Enregistrer un commentaire