Open fields in the DTO and Domain object

I am doing a code review for one project. You can see this architecture as follows:

system architecture

Currently, DTOs are simple POJOs, and Domains contain Hibernate animations. Since I know that one of the advantages of using DTO is that you can make all domain fields public and remove all this stub code using getters and setters. Is this the right approach?

What do you think of removing getters and setters from the DTO? There may also be some pros doing DTO in Groovy?

What do you think about this?

+3
source share
3 answers

I would use JavaBeans because:

  • - , JavaBeans. , .

  • . Getters seters .

  • . NullPointerException, .

, JavaBeans. .

+1

, DTO. , , , . .

, , public .

+5

The only drawbacks of creating fields open in dto is that it can cause confusion for other team members. With getters and seters, you can type get * and wait for ide to offer you all the fields.

0
source

All Articles