Search code examples
coding-stylenaming-conventionsdto

DTO's naming convention


Probably it's a simple question, but I have no clear which is the best naming convention for dto's classes and packages, in terms of package name, uppercase DTO or Dto for classes, etc... Example:

1. Package name:

xxx.dto.animal.Dog.class or xxx.animal.Dog.class

2. Uppercase dto Class Naming convention:

DogDTO or DogDto

3. Mixing both dto's conventions or neither.

The problem is, if I can declare the 'dto' word as a package or if the word 'dto' has to be included on the class name or both cases.


Solution

  • Try to avoid DTO suffix in class names. Including DTO in package names are fine.

    You just need to decide how to use it in package names. Usually, I prefer my.feature1.dto, my.feature2.dto for example.

    DTO is a very simple class so it should not be hard to recognize class to be DTO.