Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restcontroller method naming convention spring boot

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?

like image 720
user1354825 Avatar asked May 21 '26 21:05

user1354825


1 Answers

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.

like image 140
João Dias Avatar answered May 24 '26 19:05

João Dias



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!