Questions tagged [dto]

Data Transfer Objects are for moving data between processes.

Filter by
Sorted by
Tagged with
0
votes
0answers
36 views

In a DDD CQRS API, is it preferable to have a separate DTO per query or per representation of a resource?

I am in the middle of starting up a new project and just wanted some reassurance as to which approach to DTO's returned by the read-side was easier to maintain in a real world application with ...
0
votes
3answers
137 views

Domain Models with complex properties construction

According to this article: Using Ids in Domain Models is not a good practice. We should reference the entire domain model instead. In this case, when we want to provide only Getters for our ...
0
votes
1answer
53 views

Manage table relationships in Java dynamic web application that accesses a database, without using any framework

I'm developing a web application for academic purposes. What i have to do is a simple website which keeps track of realties along with their respective owners and the tags they are bound to. The ...
0
votes
0answers
254 views

dealing with too many DTO / Java

We are building an pseudo-rest API (because no body cares/funds for a full blown rest API for internal use - which is OK). So we have elements of Rest API (links for resources, API naming conventions ...
0
votes
2answers
178 views

Updating the db in the repository from a DTO in a layered architecture

Given a Person model: Person { int PersonId; string Name; string Email; } and an UpdatePersonDto which just updates the Name UpdatePersonDto { int PersonId; string Name; } How ...
0
votes
1answer
185 views

Composite DTO or flattened DTO?

I'm having problem deciding which of these 2 structures to use from my DTOs: Option 1 is: @Data class Lines{ private final Line[] lines; } @Data class Line{ private final String[] specifiers; ...
1
vote
1answer
104 views

Have generic methods that transfer DTO's from different packages, but contain same fields

I have 3 services Service A, B, C which put and get data to/from Service D +============================================+ | Service A | Service B | Service C | +==============================...
2
votes
4answers
364 views

C# class naming convention for a single item in the item list [closed]

In my C# project, I have a domain class named 'User'. this class will contain user's id, firstname, last name, DoB, home address, phone, etc. And we also have a typical REST web api (i.e. api/users) ...
12
votes
2answers
2k views

Clean Architecture: What is the View Model?

In his book 'Clean Architecture', Uncle Bob says that the Presenter should put the data that it receives into something he calls the 'View Model'. Is this the same thing as the 'ViewModel' from the ...
1
vote
0answers
161 views

How to simplify design and remove duplication in java layered architecture?

I've the following project structure (simplified): domain dto view In domain model is kept. dto classes are used to pass data from domain to view. And in view I've a controller and a handful of *req,...
0
votes
1answer
1k views

DTO vs. read model

If I understand the concept of read models correctly, then it's just a simple query to return a use case specific data set. But a DTO seems to have the same purpose, but in a more complex way (...
1
vote
1answer
813 views

Is it okay to transport a DTO inside of a DTO?

Let's suppose we have to entities, X and Y where Y is part of X, being this: class X { private int fooX; private List<Y> fooY; } class Y { private long barX; private int ...
4
votes
2answers
1k views

What data should a repository return

I have a simple project where the controller calls the service, and the service calls the repository in order to get the needed data. Assuming that we have these domain models: // this model has a ...
10
votes
6answers
990 views

Is separating most classes into data field only class and method only classes (if possible) a good or an anti-pattern?

For example, a class usually have class members and methods, eg: public class Cat{ private String name; private int weight; private Image image; public void printInfo(){ ...
9
votes
1answer
12k views

What is the use of DTO instead of Entity?

I am working on RCP application, I'm new to this application. Spring beans are used to write business logic to save/fetch entities. But, instead of sending entities directly to client we are ...
0
votes
1answer
325 views

Should I add XML comments in DTO models or entity models

I have 2 models, DTOs and database models (entities) that map to the database. I usually put XML comments above the properties to describe what are they for. class MyEntity { /// <summary> ...
5
votes
1answer
3k views

Use DTO Pattern or Serialize Domain Objects

A colleague of mine is against using DTOs and rather feels we should just return Entity / Domain objects serialized for a REST api. He feels DTO is an anti pattern and sited this article Data Transfer ...
3
votes
1answer
6k views

Data Objects for each layer(DTO vs Entity vs Response objects)

Let's say I'm building a Customer web application(in Spring Boot 2), which also exposes rest end points. I'm modeling my application into 3 layers. a) UI - CustomerDTO b) REST - ...
1
vote
1answer
138 views

Data transfer between modules (layers)

I'm creating an application that is composed using different modules (core, course, grades, news). I'm using clean architecture for the different modules but I'm stuck trying to pass data from one ...
2
votes
0answers
778 views

How to avoid DTO on a client/server application?

I would like to use DRY beans on my client-server application (DRY: Dont Repeat Yourself). It is not a problem to me if it is highly coupled: I know that my DTO will have the same form as the ...
2
votes
2answers
2k views

Can DTO contain additional helper methods?

I have a DTO like below class OnlineProfileDTO { @JsonProperty("likes") SummaryDTO likes; // lots of other complex fields similar to above } class SummaryDTO { @JsonProperty("count") int ...
1
vote
2answers
136 views

Comparing approaches of mapping data objects

Update: I added some diagrams to help understanding I had a discussion with a colleague about two different approaches in mapping data objects. I'd like to get your opinion on pros and cons between ...
27
votes
3answers
7k views

Ways to share DTO across microservices?

My scenario is as follows. I am designing a system designed to receive data from various types of sensors, and convert and then persist it to be used by various front-end and analytics services later....
1
vote
2answers
301 views

Should a REST CRUD Service that accesses a DB have 3 versions of its model

I'm building a REST service in java that does basic CRUD operations on Customers. The easy way would be for me to create one Customer model, and annotate it with JPA annotations so my persistence ...
1
vote
1answer
285 views

DTO to hold disparate data from domain model?

I have a neat domain model that makes it easy to communicate with an external web service. New requirements have made the external web service's interface messy and now I have to gather data from ...
6
votes
1answer
585 views

Should DTO have same structure as payload?

I have a usecase where I am supposed to store entire payload from a third party API in addition to the DTO, say XYZDto, its translated to. There are two ways to achieve that - Translate the payload ...
0
votes
1answer
569 views

How to handle mapping from object model to different versions of contracts or DTO's

I'm looking for patterns or best practices for maintaining different versions of an API contract. There's lots of information on the internet about how to version API's (URL's vs. headers etc), but ...
4
votes
3answers
3k views

C# - Initialize DTOs in constructor or via properties?

I was wondering if there is a recommended approach to initializing the properties of a plain object that is used for data transfer, for example via a REST-API. Here are two variants I can think of: ...
4
votes
1answer
3k views

Which C# type should one prefer for defining lists in DTOs?

I was wondering if there is a recommended approach to defining a property of a plain object that is used for data transfer, for example via a REST-API which is a list of other objects. Which C# type ...
13
votes
4answers
9k views

Use composition and inheritance for DTOs

We have a ASP.NET Web API that provides a REST API for our Single Page Application. We use DTOs/POCOs to pass data through this API. The problem is now, that these DTOs are getting bigger over time, ...
0
votes
1answer
597 views

Should I call this a DTO or something else?

In a Java/Spring MVC/Hibernate application I have model objects that contain references to other model objects where the database has foreign keys. So for example, I might have: @Entity @Table(name="...
0
votes
1answer
366 views

Is it advisable to use hashes as DTOs in Ruby when applying DDD?

It seems to me that Ruby hashes would be a good option to implement the Data Transfer Objects that the Application Services receive from the client code as commands and queries requests. For ...
0
votes
1answer
1k views

Where to put the behaviour of DTOs ? Object vs Data structure clean code

Similar question was posted here https://stackoverflow.com/questions/21064164/clean-code-how-to-design-this-class I still don't find an answer though, I'm confused! I read the book "clean code" too....
2
votes
1answer
743 views

How do you define Domain Objects and Repositories, when dealing with multiple database tables?

Imagine an application that allows you to add line items to a quote. The end result is like a sales person giving you a printed sheet with information such as name of the business, name of the sales ...
-1
votes
1answer
485 views

CQRS + Event sourcing - event groups and event propagation

This is my current CQRS use-case setup: Command DTO is received in application layer handler where we map Command DTO to appropriate domain objects if needed, re-hydrate aggregate root from repo and ...
15
votes
3answers
9k views

Sharing DTO objects between microservices

TL;DR - Is it ok to share a POJO library between services? Generally we like to keep the sharing between services strictly limited to none if possible. There has been some debate whether or not the ...
3
votes
1answer
1k views

How to name method specific DTOs representing the same entity?

I'm building a Web API. To give meaning to my controller methods I want classes that specify what properties are used for each particular operation. This would make the code easier to understand, and ...
3
votes
2answers
1k views

Using a superset DTO for a number of methods in a class

Consider a class with a number of methods that are required to return a number of values each. In a strongly typed language such as C#, we can have the effect of returning more that one value from a ...
7
votes
1answer
797 views

Reusing a top-level DTO as a child in another DTO

What is the recommendation regarding re-using DTO's as a child in another DTO? I'm using ASP.NET Web API (C#) and consuming the results with Angular 1.x (not sure if that really matters). I have the ...
1
vote
1answer
535 views

Passing information between an Adapter and the Application Layer on Hexagonal Architecture

After starting the design of a sample application with Hexagonal Architecture I got to the application layer that should be basically an API to manipulate the domain in some way. My question is: In ...
1
vote
0answers
48 views

One service facade per view

I am currently trying to design a Java EE web application. The views are quite complex, i.e. several dynamic drop down menus. The content of those drop downs may depend on the internal state of the ...
3
votes
2answers
1k views

Composition of Data Transfer Objects

Let's say I want to create a shop/order system. I'll have an Order DTO to which I'll map the data from a request and results from the database. The object will consist of an order number, a customer ...
1
vote
2answers
816 views

Creating a client side database to store consumed web services?

I have been developing android application for a while now. What we currently do is we first develop our UI components in the mean time web API developers will be completing the web APIs required, so ...
0
votes
1answer
426 views

Better way to transform data [closed]

Context Imagine complicated service that provides info about bank products, fees and so on. Imagine complicated UI that deals with it. UI and Service data formats are changed 1-2 times/month because ...
1
vote
1answer
173 views

Converting data in setters in a DTO

I wrote a simple DTO to transfer data from one point to another, or so was the initial thought. Now I just caught myself in the act of doing various things in the DTO, for simplicity's sake, like ...
0
votes
1answer
630 views

Should API DTOs be shaped to client(s) or be universal?

I have a project with an internal desktop client app and a server-side client API service talking to a relational database. I seem to have two choices: 1) shape DTOs to client views, e.g. ...
1
vote
1answer
758 views

Should DTO have validators?

I believe that DTO should be as dummy and easy as possible. However, after hint made by my friend, opportunity to validate data that is set in DTO sounds tempting. Let's have following example: //...
1
vote
1answer
1k views

DTO and JPA Version

I have DB tables representing Employees and Departments. The server side(JavaEE) contains JPA entities representing the same. The client is a standalone client and communicates with the server using ...
2
votes
1answer
954 views

Is a class representing a JSON response a DTO, a domain object, or something else?

Consider a restful service in Spring MVC. I am wondering how to package my response classes, i.e. how to name the containing package. First I thought of them as being domain objects. But they are ...
3
votes
2answers
8k views

What is the best way to create DTOs from entities and update entities from DTOs in a layered architecture?

Option 1: At first I would make a call to my service layer, which served as an API for my core domain, to get a domain object or a list of domain objects and then pass them into the assembler which ...