Data Transfer Objects

Ronald Rex 1,666 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.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
697 questions
C#
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.
10,249 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
297 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 56,026 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