Is using data transfer objects in ejb3 considered best practice

后端 未结 6 556
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-07 22:01

Although obviously not all scenarios can be covered by a single design, is it generally felt now that ORM classes should be passed to and fro between the presentation and busine

6条回答
  •  北荒
    北荒 (楼主)
    2021-02-07 22:32

    Tight coupling? Please explain.

    As for me DTO is an Anti-Pattern. EJB3 allows us to omit using them. You can just force your lazy initialization before sending Entity to the client.

    Of course if you need only two of 30 fields to send to a client you just send them. But if is the whole copies all the time as in my current project -- try to get rid of that DTO. I don't see any reason to use them. You send a business object to the client as a client asked. Why to use wrapper?

提交回复
热议问题