WebApi: Naming convention of Web API controller methods

Viewed 28

I was searching for the naming convention standards for Web API controller methods.

Note, I am not searching for the web API route naming convention but the web api controller method name.

The specific question I have is that if I have a controller method with explicitly specified HttpGet attribute then should I start its name with the word Get?

So for example should I name my controller method with GET verb as GetUserAddress or just UserAddress since the verb already says that it is a get method?

I searched many posts but all of them talk about the route naming convention and not the controller's method naming convention

One this post I found but could not get my answer in this as well

Method name conventions in Web API 2

EDIT

This gives some answer but I am still not clear with my specific question

https://docs.microsoft.com/en-us/aspnet/web-api/overview/older-versions/creating-a-web-api-that-supports-crud-operations#getting-a-resource

1 Answers

The naming conventions of web API controller methods are just like other methods in any class. it must respect all naming conventions rules as Uncle bob mentions in his book clean code Naming Convention.

If the method name respects these rules, it will be fine. Microsoft added the prefix "Get" at naming although on the other side some developers use the prefix "Load" or "Fetch"

Conclusion: if the method of naming respects the rules of naming conventions, no need to be worried about it.

Related