mercredi 16 août 2017

Pros and cons of having one controller for multiple resources

We have a Spring MVC application, most of the REST operations are the only GET operation per resource. So currently we have many controllers with the only GET method that doesn't differ from each other (even in urls, content types, parameters and etc).

In order to remove such a duplication our team mate offers to make one controller with the only GET operation and a map with service (resource name -> resource service).

But we see such downsides as more complicated Spring injection tuning, no opportunities to add some restrictions on content types, parameters - customize operation in one word. Additionally, there are several resources that are to reside in a separate controller. Also I don't expect there is at least easy way to document the only method in Swagger in multiple ways (have different description).

So as for me on the one side is less code but on the other are restricted opportunities of operation customization, mix of architectures, lack of proper documentation or at least complicated configuration. I don't think it is a good approach here to make one method.

Am I right? If so how can I prove it. If not why? Thank you for you time and ideas!

Aucun commentaire:

Enregistrer un commentaire