Skip to main content

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.

7
  • The question is not so much if you call a de serialized object from a JSON response a dto or "an-object-from-the-wire". The question is: Is it ok to manipulate the prototype chain of such an object that I de serialized from JSON? If you call the result of such an operation a dto or something else is not the point for this particular discussion... I agree that architecture is not a religion and you have to decide for your particular application what's best. Commented May 4, 2023 at 21:00
  • 1
    @morpheus05: The question about prototype cannot be answered before you explain the reasons why you have DTOs. What exactly are these reasons? If all attributes of objects in DB and in DTOs are the same, then you don't need DTOs. If there are reasons to have DTOs (e.g. you want to separate REST layer from the business logic layer, or you validation of DTOs, etc.), then changing prototype will break these reasons. So, please answer, why do you have DTOs at all? Commented May 4, 2023 at 21:37
  • 1
    A) How would you name an object you parse from a JSON response? - You first name, then parse. If you need DTOs, this can be DTO. If you don't use DTO layer, this can be BO. As I said, first decide if you need DTOs. Commented May 4, 2023 at 22:34
  • 1
    B) "for that case where they are not you introduce dtos into your application" - Do you mean, there are DTOs and it was not your decision, and you cannot change it? If yes, then again, first ask what is the reason for DTOs. If there is a reason, then changing prototype can break it. If there is no reason, don't use DTOs. Commented May 4, 2023 at 22:37
  • 1
    We cannot discuss abstract cases, with unknown reasons for particular decisions. That's why please be specific. Describe a specific case (or few specific cases, each separately), explain what were the reasons to use DTOs. Only then we can proceed to the question about prototypes. Commented May 4, 2023 at 22:44