0

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.

2
  • 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
    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? Oct 12, 2021 at 1:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.