Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transfer Object Across Multiple Tiers?

 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it okay to have a Business Object get a Transfer Object from a Data Access Object and return the Transfer Object as is to the web tier? I was thinking that the business objects could translate the transfer object they get back into an object of a different class before returning the data to the web tier but that seems like it would be really inefficient. Can anybody advise me on this? By the way, I'm talking about no more than 50 transfer objects being returned from the DAOs that only contain 5-10 primitive typed attributes and no object graph. Thanks a lot for any advice. I've been going over this in my head for a couple days now.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say it's ok to pass on the DTO's. If it becomes a problem, you can change it later. If you want to be sure you don't tie your web tier too closely on the middle tier, you could introduce an interface for each DTO to add flexibility.
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I think introducing an interface, as you suggested, is the way I'll go on my project.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic