Skip to main content

Questions tagged [dto]

Data Transfer Objects are for moving data between processes.

Filter by
Sorted by
Tagged with
1 vote
5 answers
473 views

DTO vs POJO (Entity) on POST request

If I have for example a User POJO like the following @AllArgsConstructor public class User { @Id private final String id; private String username; private String password; private Date createdDate;...
iqueqiorio's user avatar
2 votes
4 answers
662 views

Is it a code smell to modify a data transfer object (DTO) within a loop in a Spring service controller?

I have a Spring service that acts as an adapter for another service in my company. The service receives a request to generate push notifications for a given user and needs to call the other service ...
VariabileAleatoria's user avatar
1 vote
4 answers
2k views

Validating data classes with nullable properties that should never be null

When retreiving data with an api and saving it in a DTO, some values are nullable: null on initial class initialization but VS also warns you for this. For example, an employee: public class ...
Jannick Breunis's user avatar
2 votes
1 answer
237 views

How to properly use Data Transfer Objects

I feel something is wrong with my approach handling MVP and the Repository Pattern. I'm making an album winform app just to practice MVP, crud and the Repos. Pattern. First some code. The model: using ...
Valmont's user avatar
  • 183
0 votes
1 answer
2k views

Three layer architecture and using DTOs to transfer data between layers

I have a 3 layer architecture application with presentation layer, business layer and data access layer. UI -> BLL -> DAL UI Layer has reference to only BLL and BLL refer only to DAL. My BLL has ...
Alfons Deda's user avatar
1 vote
2 answers
2k views

Is it OK to return different DTOs for the same endpoint when the user is logged in vs when it is anonymous?

Say that I have a REST endpoint for a chess server. If I'm not logged in and do a GET on /games I could get all running games like: { running_games: [ ..... ] } but if I'm logged in I ...
tonicebrian's user avatar
-1 votes
1 answer
312 views

Do usecase-class work with domain-model or data-model at cleanarchitecture?

I interessted in the "usecases" and "how they interacts with the "context" at "clean architecture". If I understand right, there will be two contexts. First is the ...
Cit's user avatar
  • 21
0 votes
3 answers
1k views

CRUD service with or without DTOs

I'm about to create a service providing a simple CRUD Json REST-API. The main requirement is that documents stored/received always conform to a schema provided as JSON schema. So here's the thing: ...
Jan Gassen's user avatar
0 votes
1 answer
987 views

Mapping destination object from multiple source objects vs constructing using multiple source objects (as in constructor)

Lets say we have DTO class with 15 properties. Usually DTOs like these are mapped from other objects. But sometimes some DTOs may use values from multiple objects. In these cases, should we “Map” or “...
Gintaras's user avatar
0 votes
0 answers
357 views

.Net Core Api - multiple Dto’s for single entity

I want to know the best Practice is about having multiple dto’s for different use cases. Let’s say we have an api with a set of controllers to handle requests coming from a administration backend and ...
Martin C's user avatar
0 votes
1 answer
160 views

Best mapping practices in an enterprise application

This question might seem like a trivial question. But here it goes. Currently, I'm working with this .NET Core application, an N-tier application consisting of a Vue frontend, business logic layer, ...
XRaycat's user avatar
  • 131
2 votes
4 answers
4k views

Is it a bad practice to use transformation functions within DTO objects

I'm looking for some guidance. Is it a bad practice to use transformation functions within DTO objects? I have this example public partial class AgEmpDto { private DateTimeOffset ...
Udemytur's user avatar
  • 195
0 votes
1 answer
71 views

MVVM List<T> from Model to View

I am writing a control app for a 6-DOF robot. This app can send scripts to the robot, which in turn executes these and thus moves around. In the app a robotprogram can be created by adding 3D ...
Gertjan Brouwer's user avatar
1 vote
3 answers
1k views

Should the Use Case be responsible for transforming its primitive parameters into typed data for the Entity to use?

I'm building a Use Case for creating blog posts, this Use Case has its own "DTO", which is basically a parameter object with only primitive data, as follows: Use Case's DTO (Parameter Object)...
Thiago Dias's user avatar
1 vote
0 answers
770 views

Should I run validation logic on the DTO or the entity model?

Suppose I have a Controller that takes a DTO that represents an Order. This DTO has inner DTOs that could potentially have entity IDs and/or entity data that's used to create an entity dynamically ...
Morgan's user avatar
  • 111
1 vote
1 answer
585 views

Dealing with business logic on DTOs using a DDD

I have a scenario in which an Entity defines an EntityRepresentation that is created from another end. The EntityRepresentation is a value object that implements some logic that should be performed on ...
Antonio Santoro's user avatar
2 votes
3 answers
7k views

When to use entity and when to use DTOs

Hi I am very new to using DTOs, and I am starting to understand it slowly, but there are still some missing puzzles for me. I understand the use of DTOs in the way of decoupling the persistence data ...
user9347049's user avatar
0 votes
2 answers
3k views

Is it okay to add userId to a DTO object?

I'm implementing the validation layer for a certain method on a controller, namely I need to check if certain image ids passed do really belong to the user making a request. In order to do that I need ...
Albert's user avatar
  • 109
0 votes
2 answers
906 views

Design of DTO-Objects for an API with dynamic table design

We have a table design in our database to dynamically store settings: You wouldn't need to understand every column in the table but basically tbl_Setting defines all possible settings and ...
OPunktSchmidt's user avatar
6 votes
2 answers
4k views

Data Repository and Complex Queries (DTO)

Following the classic 3 layer architecture domain Model (a list of domain models live there and has no dependencies) DAL layer - My Repositories lives there with DBContext implementation (Ado.net) ...
Stelios's user avatar
  • 203
2 votes
0 answers
593 views

How to retrieve login token from repository in network layer? Domain Driven Design - DDD

I am trying to come up with a design for an application I am working on. Here is a basic picture of what I am looking to do. Everything up to the Data Layer is totally fine but the Data Layer makes ...
Muhand Jumah's user avatar
4 votes
3 answers
1k views

Should the DTO be able to parse itself from and to Domain?

Let's say there's the class Book, with different models in different endpoints: Endpoint A (consumer): class Book{ Map<string,string> chapterName_content } Endpoint B (provider): class Book{ ...
Carlos Coelho's user avatar
1 vote
2 answers
2k views

How to share entity classes (JPA) among projects, where not all have DB access?

So, I have project in which several WebServices will be created (REST). For the sake of simplicity, Lets name them A, B, and C. A and B handle different tasks, but both of them consume C, which is the ...
SonneRevsson's user avatar
0 votes
2 answers
1k views

Separate DTOs consequently for each module?

Following the hexagonal architecture and package design you will have somewhere an entry point reaching to your core functionality. Often this is done by using a facade. To hide the core logic from ...
Jim Panse's user avatar
  • 398
0 votes
1 answer
557 views

Different fields for GET and POST methods in REST

I have a collection /users/{userId}/tools and I want to GET and POST to that collection. Can I have different representation of that object based on the method? For example, for POST I want to send ...
TheEmpire12's user avatar
2 votes
1 answer
4k views

Is it necessary to have DTO to domain entity mapping always?

I am working on a WebAPI application which follows the layered approach like Controller > Service Layer > Repository Layer > Entity Framework Core (SQL / Cosmos) The view is in Angular. In many of ...
Guru Pasupathy's user avatar
0 votes
1 answer
7k views

Best practice for references in DTOs and entities in Spring

Given the following architecture and frameworks: Spring Boot Application with Spring Data JPA (Hibernate is used as OR mapper); layered architecture as followed. REST layer Service layer Persistence ...
keezar's user avatar
  • 27
-6 votes
1 answer
143 views

Are aspects of domain driven design limiting when we scale?

From what I have read about the domain driven design, an aspect of it is that there is a clear separation between domain objects and DTOs. So the application level components deal with domain objects ...
Jim's user avatar
  • 327
-2 votes
1 answer
354 views

Is there a design pattern for transferring "partial" or related data objects?

I am writing a program in Kotlin which parses some input data and writes it to a MySQL database (through JDBC). The database includes tables such as users and each table has a corresponding data ...
Farbod Salamat-Zadeh's user avatar
-1 votes
1 answer
109 views

Defining characteristics of mutable data structure objects

Assume we have data structure objects - some of them are DTOs and some of them are VOs. Also assume that Value Objects are immutable and Data Transfer Objects are immutable and readonly, then: How ...
Daniel Iwaniec's user avatar
0 votes
1 answer
1k views

Mapping bidirectional 'toMany' relation from DTO to entity

The application that I am working on has numerous ...toMany relations, e.i. class Model can have several parameters. In Unidirectional world, it is simple to manage a collection. I can clean the ...
Serafins's user avatar
  • 119
2 votes
4 answers
1k views

Role of DTOs in Rich Domain Model

I work with Spring applications. Recently I have found this article about the Anemic Domain Model. They recommend putting logic in Entity classes. It solves a problem that Martin Fowler described in ...
Valerii Sloboda's user avatar
-2 votes
1 answer
377 views

Centralized REST API call management?

I was given a solution with many projects. Multiple projects call multiple REST APIs. These calls are scattered around the spaghetti code. Trying to figure out what calls are done in what sequence ...
user2263986's user avatar
3 votes
4 answers
468 views

What is optimal number of entity abstraction levels?

Sorry about the vague question, please do suggest different formulations. Anyway here is the kernel of the question: How many classes representing an entity/resource or whatever you want to call it, ...
Pavel Schoffer's user avatar
1 vote
1 answer
163 views

How to add supporting information to the existing java object?

Is there a way or design pattern to add supporting information to the existing java object? Example I have a model class Parent and it has child models. Its nothing but hibernate entities with parent-...
Javee's user avatar
  • 19
1 vote
2 answers
255 views

Looking for clarification on pub/sub systems and how an API gateway comes into play

I'm new to micro service architecture and I'm looking to understand how services should/can interact with each other. The acceptance for my current story requires me to: Email a document Backup the ...
furiousgreg's user avatar
11 votes
3 answers
16k views

Is it anti-pattern to have inheritence in a dto?

Are data transfer objects or POJOs meant to be final or can they be extended and create hierarchies for them? It is not clear to me if such a value class is properly designed only as a final class and ...
Jim's user avatar
  • 327
4 votes
3 answers
2k views

REST API: what should PUT do with complex objects?

Let's suppose I have the following objects in my domain: class Warehouse { int Id; string Address; Item[] Inventory; } class Item { int Id; string Name; int Price; int ...
user avatar
2 votes
1 answer
742 views

DTO Design in Depth

I'm extending an existing application, which has an attempt at a logical tier design, using DTOs, a Services layer (business logic), and a DAL. However, as I'm investigating more about DTOs, my ...
HardCode's user avatar
  • 644
-2 votes
2 answers
345 views

Is using a pattern on a completely wrong way a terrible mistake [closed]

This is maybe a strange question, but I just trying to understand my colleague. I know what is DTO, and what should be on it, but not that long time ago I found the whole micro-service written on the ...
Darkves's user avatar
  • 107
0 votes
0 answers
771 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 ...
Too Many Questions's user avatar
0 votes
3 answers
2k 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 ...
Dree Droo's user avatar
0 votes
1 answer
602 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 ...
cidra's user avatar
  • 343
1 vote
0 answers
2k 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 ...
Dexters's user avatar
  • 135
1 vote
2 answers
3k 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 ...
Chris Herring's user avatar
1 vote
1 answer
2k 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; ...
Bojan Vukasovic's user avatar
1 vote
1 answer
788 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 | +==============================...
Alex P.'s user avatar
  • 121
2 votes
4 answers
3k 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) ...
yyou's user avatar
  • 131
25 votes
2 answers
13k 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 ...
Fearnbuster's user avatar
1 vote
0 answers
502 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,...
Opal's user avatar
  • 275