Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data Transfer Object / Value Object

 
Manoj Zachariah
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i create a DTO to pass multiple values between classes
 
David Peterson
author
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DTOs (Data Transfer Objects) are plain old Java objects. Nothing fancy, just a bunch of get/set methods. Don't define any business logic in your DTOs. All they do is hold data.
Hope this helps.
David Peterson
 
Sadanand Murthy
Ranch Hand
Posts: 382
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Manoj Zachariah:
How do i create a DTO to pass multiple values between classes

Just like any other java class. All variables that hold the values for the various attributes (that you want passed to other classes) should be private (unless you want to create subclasses & want subclasses also to be able to directly reference these vars). You expose these variables (or the values they hold) via get/set methods (ex: getCustomerName(), setCustomerName()).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic