Apologies for the "pedantic" question, however I have been wondering how to structure the following. If I am building a JPA type application, my persistent classes (annotated with @Table etc) may be collected in a foo.bar.entities package. However, I may also have objects that are of a similar structure (POJO) that are not use for persistence. Where would I place these so that it was clear that there function was other than JPA; foo.bar.dto (for data transfer object) - or am I confusing my terminology? Maybe they are "model" classes - although that is really what the entities are?
Asked
Active
Viewed 51 times
1
-
1This is highly opinionated and the answers probably also will. For instance see http://programmers.stackexchange.com/questions/258196/java-application-structure-horizontal-vs-vertical-split/258197#258197 and http://stackoverflow.com/questions/533102/what-strategy-do-you-use-for-package-naming-in-java-projects-and-why. – M. Deinum Apr 18 '16 at 05:47
-
Thanks - I will have a read of these – skyman Apr 18 '16 at 06:02
1 Answers
1
Term 'dto' is mostly used to refer to these kind of objects. Use vertical slice architecture to place these classes under a different package.
Now, you can place dto's under dto package and entity/domain classes under domain package. You can also use entities as your package name, but just be consistent all across your project with your naming conventions.

asg
- 2,248
- 3
- 18
- 26