addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupsimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1outlookpersonJoin Group on CardStartprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

Re: [ljc] DTO as an anti-pattern?

From: Ged B.
Sent on: Monday, January 14, 2013 9:33 AM
Hi Craig,

That makes it easy to rule out annotating the entity objects with Jaxb directly.  That only makes sense when all clients are using the same object boundaries.  For example, if you have a canonical data model.  

The question remains: do you want to use DTOs.  With DTOs you are introducing a whole new set of classes that you have to look after.  If all you are doing is marshalling those objects into a text document to stream over a network then it will be much easier to take a dynamic approach.  For example, using a map.

I would say the only reason to go to the trouble of declaring a whole set of DTO classes is if you are going to share them with a client so that they will take advantage of static typing.  

Will you share your DTOs with a client, or will you only ever use them for generating a message document?



On Sunday, 13 January 2013, Craig Silk wrote:
Ged - The real issue here is, is it ok to annotate entities with JAXB annotations and have to provide logic to decide what gets marshalled depending on the request or should I use DTO's to hold the data from the entities and annotate the DTO's so the whole thing gets marshalled and I can decide which DTO to populate based on what comes in the request?


Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Craig Silk ([address removed]) from LJC - London Java Community.
To learn more about Craig Silk, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]

Our Sponsors

  • Our Blog

    Read the latest news from the LJC

  • RecWorks Ltd

    Fixing Tech Recruitment using the Power of Community

  • jClarity

    Java/JVM Performance Analysis Tools & mentoring for Java related matters

  • LJC Aggrity

    Our LJC Aggrity site contains blog posts from our members

  • LJC Book Club

    Our Book club with book reviews from our members

  • Devoxx UK

    Java Community Conference in collaboration with the LJC, 8-10th June 16

  • SkillsMatter

    "Host, help organise, promote, film many of our meetings."

  • IBM

    Build Enterprise-grade apps at start-up speed.

  • New Relic

    New Relic makes sense of billions of metrics a day in real time.

  • Hazelcast

    Hazelcast is the leader in operating in-memory computing.

  • Java.Net

    We are an official Java User Group recognised by Oracle's JUG program

  • JRebel

    Free 3 month J-Rebel license.

  • O'Reilly

    40% discount on printed books and 50% on e-books.

  • Craft Rebellion

    Your choice of fresh craft beer, delivered. For 10% off use ‘LJC'

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy