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.
Required fields*
- 4"When is it advisable to separate DTO from JSON?" Never? That's one of the main reasons DTOs exist: to serialize them into any format you want. Would you also create a separate class for XML? CSV? All of them exactly the same? Form over content.freakish– freakish2024-12-03 06:17:18 +00:00Commented Dec 3, 2024 at 6:17
- 7"We know that entities that are also DTOs and also REST API JSONs won't pass code review": So, your company has a guideline that doesn't allow that. Depending on the project complexity, and ignoring any company guidelines, anything can be a good solution, from one-class-does-it-all to a confusingly complex zoo of classes and interfaces, all representing the same concept, just for different purposes. Whoever tells you "you have to do it exactly this way" should also state the circumstances where this advice applies.Ralf Kleberhoff– Ralf Kleberhoff2024-12-03 08:03:54 +00:00Commented Dec 3, 2024 at 8:03
- 1@RalfKleberhoff Thank you for your comment. Please post it as an answer and I will accept it. In the answer, if you could elaborate on an example that justifies not following the "Never" rule explained in the previous comment, that would help me better understand.sfinja– sfinja2024-12-03 13:50:06 +00:00Commented Dec 3, 2024 at 13:50
- 2On second thought, I voted to reopen. There are some valid technical considerations that affect this decision even if there is an element of subjectivity to it.Greg Burghardt– Greg Burghardt2024-12-03 14:27:58 +00:00Commented Dec 3, 2024 at 14:27
- 3This question seems to be built on inaccurate language. Case in point: "separate JSON classes allow us to handle version-specific serialization without affecting your internal DTOs, right?" What you're referring to as "JSON class" here is what is commonly referred to as a DTO. What you're referring to as an "internal DTO" is generally referred to as a domain model (or similarly private data structure).Flater– Flater2024-12-03 23:14:38 +00:00Commented Dec 3, 2024 at 23:14
| Show 2 more comments
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
lang-java