79266469

Date: 2024-12-09 21:15:45
Score: 0.5
Natty:
Report link

They are in different packages but I think it's confusing to have the same name. Is there a best practice on how to name the transfer objects?

I feel comfortable using DTO or any module-suffix at the end of the class, for example somethingController, somethingRepo... it makes finding something easier. In normal cases, CarDTO is a good choice, but if I am concerned about name duplication I will add a package prefix. Similar to how two students with the same name in a class are distinguished by their last names. In your case, I'd name it clientCarDTO/clientapiCarDto.. And...

What about situation when I have multiple DTOs of the same class? – Flying Dumpling

If the action forces me to separate multiple DTOs for multiple actions, I will choice an action-suffix (eg. userRegistrationDTO, userProfileDTO,..) for the name. If different objects force to write separate DTOs for them, I will name them with the suffix ...bySomeoneDto (eg. accountCreateByFooDTO, accountCreateByBarDTO,...).

Reasons:
  • Whitelisted phrase (-1): In your case
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: trongtoannguyen