Are there conventions for naming methods in the Restful spring boot conrtoller layer ? I am in dilemma choosing the two name - getSomeData vs fetchSomeData. Is it OK to use HTTP Verbs (get,post,put) inside controller method names?
Are there conventions for naming methods in the Restful spring boot conrtoller layer ? I am in dilemma choosing the two name - getSomeData vs fetchSomeData. Is it OK to use HTTP Verbs (get,post,put) inside controller method names?
I think the most important thing is to be consistent in all your Controllers and to be explicit about what the method is supposed to be doing. It is completely ok to use HTTP verbs in the method names, especially in regards to GET. But when you have POSTs for example, that is usually a creation of a resource, so a method called createWhateverResource instead of postWhateverResource. The important thing is to be clear and let the name of the method be self-explanatory.
I checked a bit on the net. My conclusions:
A related note - for methods returning HTML (using Thymeleaf templates) I would probably call the methods by the page that they return: home(), orderDetails(), etc. Again for the same reason - we never call the methods directly. At the same time, it is very clear that @Controller and @RestController classes contain only methods returning HTTP responses to specific endpoints. Therefore, the verbs are probably not necessary.