I wonder if there is a naming convention or a best practice to name Java Classes when building AWS Lambda functions with Java for REST API?

For example, if I have a Java project that contains Lambda functions to handle CRUD operations, is it a good practice to name Java classes this way:

  • PostHandler.java - A Java class with requestHandler() method to handle HTTP Post request
  • GetResourceHandler.java - A Java class to handle HTTP Get request to return a single resource,
  • GetResourcesHandler.java - to return multiple resources, PutHandler.java - to update a resource,
  • PatchHandler.java - to partially update a resource,
  • DeleteHandler.java - to delete a resource.

What if each Handler class uses a Service class to encapsulate each business logic. How do you name Service classes? Are the following names a good practice?

  • CreateResourceService.java

  • UpdateResourceService.java

  • PatchResourceService.java

  • DeleteResourceService.java

  • GetResourcesService.java

  • GetResourceService.java

Would very much appreciate it if you share how you name classes in your project.

  • 1
    What you call a "service" sounds more like a command pattern to me since every class encapsulates just one action. Alternatively, if you apply CQRS, you could call every CUD operator, a command, and call Query to the R operations from your CRUD.
    – edalorzo
    Commented Oct 12, 2021 at 0:45
  • Thank you, @edalorzo! I am not very sure I want to apply CQRS pattern here… makes a small service too complex. Have never come across a AWS Lambda project that uses Command pattern for CRUD operations either. I have seen projects that put all these operations into a single Service class. But since Lambda functions should be independent front each other, I wondered if making handler methods use the same service class is a good idea. So I wondered how other developers do it in their serverless aws lava Lambda projects? How do they name their classes? Commented Oct 12, 2021 at 1:17

1 Answer 1


The naming conventions you've provided are generally a good practice. The names are clear, descriptive, and reflect the purpose of the class.

For the Service classes that handle the business logic, using names that indicate the action being performed is also a good practice. The names you've provided, such as CreateResourceService.java, UpdateResourceService.java, and DeleteResourceService.java, clearly indicate the purpose of the class. Additionally, it is also a good practice to use a consistent naming convention throughout the project.

Another naming convention could be that the service classes that handle the business logic could be named after the resource they're handling - for example, ResourceService.java and ResourceHandler.java

It's also good to note that in the end, the naming convention you choose must be consistent and should make sense for the project. I hope I have helped you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.