DTO and business logic/validations


EJB design: DTO and business logic/validations

  1. DTO and business logic/validations (1 messages)


    What should a DTO be composed of?
    Is it recommended to have validation outside and just infer the results in DTO in terms of boolean.This way I do not have to keep on repeating logic in web tier as well as in middle tier.

    For instance consider this...

    I have to check if custNumber appears in sorted order for front end but my back end is expecting it in some other sort order and the bridge between them is DTO.
    I would be essentially duplicating the sort code in both web/back end tier.
    Can I have this sort logic in DTO itself or have getters and setters for getting the sort order in DTO for both tiers separately and have helper class sort it accordingly.

  2. DTO and business logic/validations[ Go to top ]

    What validation are you refering to?

    I don't think you should have that (sorting) logic in DTOs. With that you would be tying you data fetches to some logic for handling that data. I think that should be left to whichever object (may be DAOs) who are going to be receiver of this DTO.

    - PI