Share via

Data Transfer Objects

Ronald Rex 1,671 Reputation points
2022-08-24T06:14:41.39+00:00

I just have a quick question concerning DTO's. I read that DTO's are useful for security purposes e.g. they prevent you from sending confidential data across the network. But the tutorial also said that DTO's are also useful in the case that if there is a change to the API, DTO's prevent your application from breaking. Could someone please be kind enough to show me an example or explain how this would work. Is this simply saying that you use DTO's so that you are not directly calling the web API for your Data? I'm a little confused and any help would be greatly appreciated.

Developer technologies | .NET | Entity Framework Core
Developer technologies | ASP.NET | ASP.NET API
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


Answer accepted by question author

  1. Bruce (SqlWork.com) 83,821 Reputation points
    2022-08-24T16:16:12.977+00:00

    Data Transfer Objects are used pass data between two process. They differ from business objects in that they have no methods, they are data only. Because they have no methods, api changes in the processes typically have no impact. Of course adding new data elements to the DTO will be a breaking change.

    A webapi or a business layer should return DTO's rather than Business Objects. They should be an abstraction of the underlying data, so processing logic or data store changes have as little impact as possible.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.