Questions tagged [dto]

Data Transfer Objects are for moving data between processes.

Filter by
Sorted by
Tagged with
0 votes
3 answers
176 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: ...
user avatar
0 votes
1 answer
69 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 “...
user avatar
0 votes
0 answers
96 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 ...
user avatar
0 votes
1 answer
62 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, ...
user avatar
  • 111
2 votes
4 answers
567 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 ...
user avatar
0 votes
1 answer
45 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 ...
user avatar
1 vote
2 answers
148 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)...
user avatar
0 votes
0 answers
216 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 ...
user avatar
  • 101
1 vote
1 answer
236 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 ...
user avatar
1 vote
3 answers
975 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 ...
user avatar
0 votes
2 answers
974 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 ...
user avatar
  • 109
0 votes
2 answers
179 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 ...
user avatar
2 votes
2 answers
1k views

Data Repository and Complex Queries (DTO)

Following the classic 3 layer architecture domain Model (a list of entities live there and has no dependencies) DAL layer - My Repositories lives there with DBContext implementation (Ado.net) Dal ...
user avatar
2 votes
0 answers
405 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 ...
user avatar
4 votes
3 answers
528 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{ ...
user avatar
1 vote
2 answers
895 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 ...
user avatar
0 votes
2 answers
461 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 ...
user avatar
  • 253
0 votes
1 answer
227 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 ...
user avatar
1 vote
1 answer
2k 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 ...
user avatar
0 votes
1 answer
5k 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 ...
user avatar
  • 27
-6 votes
1 answer
124 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 ...
user avatar
  • 297
-3 votes
1 answer
164 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 ...
user avatar
-1 votes
1 answer
79 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 ...
user avatar
0 votes
1 answer
581 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 ...
user avatar
  • 119
1 vote
4 answers
632 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 ...
user avatar
-2 votes
1 answer
235 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 ...
user avatar
3 votes
4 answers
397 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, ...
user avatar
1 vote
1 answer
109 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-...
user avatar
  • 19
1 vote
2 answers
131 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 ...
user avatar
10 votes
3 answers
9k 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 ...
user avatar
  • 297
4 votes
3 answers
1k 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
575 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 ...
user avatar
  • 604
-2 votes
2 answers
335 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 ...
user avatar
  • 107
0 votes
0 answers
384 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 ...
user avatar
0 votes
3 answers
1k 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 ...
user avatar
0 votes
1 answer
516 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 ...
user avatar
  • 299
1 vote
0 answers
1k 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 ...
user avatar
  • 135
1 vote
2 answers
2k 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 ...
user avatar
1 vote
1 answer
1k 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; ...
user avatar
1 vote
1 answer
367 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 | +==============================...
user avatar
  • 121
2 votes
4 answers
2k 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) ...
user avatar
  • 131
22 votes
2 answers
9k 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 ...
user avatar
1 vote
0 answers
234 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,...
user avatar
  • 275
6 votes
1 answer
9k 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 (...
user avatar
  • 396
2 votes
1 answer
5k 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 ...
user avatar
17 votes
2 answers
11k 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 ...
user avatar
  • 341
11 votes
7 answers
2k 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(){ ...
user avatar
  • 5,582
45 votes
1 answer
57k 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 ...
user avatar
0 votes
1 answer
888 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> ...
user avatar
  • 1,421
8 votes
2 answers
8k 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 ...
user avatar
  • 849