Skip to main content

USE strict method names for controller actions

Developers should follow strict method names for each HTTP verb in a controller because it helps to improve the readability and maintainability of the codebase, and it also ensures that the API endpoints are consistent and easy to use.

When creating a controller in a web application, each HTTP verb (GET, POST, PUT, DELETE, etc.) corresponds to a specific action that the controller can perform. By using strict method names for each HTTP verb, developers can create a clear and consistent naming convention that makes it easy to understand what each method does and which HTTP verb it corresponds to.

For example, if you have a controller for managing users, you might have a method called "QueryUsers" for handling GET requests that retrieve a list of all users, and a method called "UpdateUser" for handling PUT requests that update a specific user.

Following strict method names for each HTTP verb also makes it easier to create RESTful APIs, which rely on a set of standardized URLs and HTTP methods to manage resources. By adhering to the expected naming conventions for each HTTP verb, developers can ensure that their API endpoints are consistent and intuitive, making it easier for other developers to understand and use their APIs.

For each HTTP verb a standardized method name is chosen by our engineering team and implemented throughout all solutions we have on board.

  • To retrieve a list of a resource - HTTPGET QueryResources
  • To create a single resource - HTTPPost CreateResource
  • To retrieve a single resource with id - HTTPGET GetResource
  • To update a single resource with id - HTTPPUT UpdateResource
  • To update a spesific field of a resource with id - HTTPPATCH PatchResource
  • To delete a single resource with id - HTTPDELETE DeleteResource