I am a software design engineer having experience on design and developing software systems. My favorite development tools are Java, Spring Boot and JS technologies.
The reason is that your entity might have more parameters and your client doesnt need all those parameters. So, you create a DTO of what parameters your client want. For an example, client wants only name and age of an user. However, your entity has more information than that like telno, address, designation etc. Therefore, in order to provide what client wants, you create your custom DTO that contains only name and user property.
I understand. But in the case of return the same properties. It should be better return the entity instead of "duplicate " the object contract? Thank for the response.
I am a software design engineer having experience on design and developing software systems. My favorite development tools are Java, Spring Boot and JS technologies.
The reason is that your entity might have more parameters and your client doesnt need all those parameters. So, you create a DTO of what parameters your client want. For an example, client wants only name and age of an user. However, your entity has more information than that like telno, address, designation etc. Therefore, in order to provide what client wants, you create your custom DTO that contains only name and user property.
I understand. But in the case of return the same properties. It should be better return the entity instead of "duplicate " the object contract? Thank for the response.
You can do that if you need to return exact entity.