You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
- 12I can not tell you what should you do, but to my experience working with DTO, inheritance and composition sooner than later hunt you like a bad coffee. I will never reuse DTO again. Ever. Plus I don't consider similar DTOs to be a DRY violation. Two endpoints that return the same representation can reuse the very same DTOs. Two endpoints that return similar representations are not returning the same DTOs so I make specific DTOs for each. If I were forced to choose, the composition is the less problematic in the long run.Laiv– Laiv2017-07-17 14:44:52 +00:00Commented Jul 17, 2017 at 14:44
- @Laiv this is the correct answer to the question, just don't. Not sure why you put it as a commentTheCatWhisperer– TheCatWhisperer2017-07-17 15:23:25 +00:00Commented Jul 17, 2017 at 15:23
- 3@Laiv: What do you use instead? In my experience, people who struggle with this are simply overthinking it. A DTO is just a container for data, and that's all it is.Robert Harvey– Robert Harvey2017-07-17 15:26:41 +00:00Commented Jul 17, 2017 at 15:26
- 1TheCatWhisperer because my arguments would be mainly opinion based. I'm still trying to address this kind of problems in my projects. @RobertHarvey true, don't know why I tend to see things harder than they really are. I'm still working on the solution. I was quite convinced that HAL was the model meant to solve these problems, but reading your answer I realised that I do my DTO too granulars too. So I will put in practice your approach first. The changes are going to be less dramatic than shifting completely to HATEOAS.Laiv– Laiv2017-07-17 17:58:05 +00:00Commented Jul 17, 2017 at 17:58
- Try this for a good discussion that might help you: stackoverflow.com/questions/6297322/…johnny– johnny2017-07-17 20:11:43 +00:00Commented Jul 17, 2017 at 20:11
Add a comment |
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you