Matthew J. Vincent wrote:
Hi all,
Thanks for the info. Here's another issue.
What if I have an employee search screen that wants to show only some of the information of an employee (not all). What do you do then?
1. Instanatiate an Employee object and only fill in the relative information? Keep in mind that this could be just employee name and location on the search results screen and then when the user chooses which employee to view I need to get all of the employee information.
2. Instantiate an Employee object and fill out all the information even though you won't be needing most of it on the search results screen?
3. Create 2 DTOs, one called Employee and one called EmployeeSearch DTO. The EmployeeSearch DTO only stores what needs to be shown on the search results screen and the EmployeeDTO holds all the information for what needs to be shown on the detail screen?
4. Something else...
I wouldn't make new DTOs/Value Objects. I'd just do number 1 above: "Instanatiate an Employee object and only fill in the relative
information?" OR sometimes 2 is ok if it's not a big query, that way could reuse your query. BUT, you also mention that are doing this based on a "search," often for that what you search on won't necessarily even be in the EmployeeDTO so I often DO make a SearchDTO to pass to my service layer. For example maybe you want to search on employees who have been hired before a certain date and after a date. You then would have a startDate and endDate in your searchDTO. I susually always end up with a searchDTO for when I need to capture criteria to search on. But if say for displaying a list of Employees that the user can pickf from.. I'd simply reuse the basic Employee object, even if it's only populated with a name and ID.
By the way, I recommend you look at iBATIS for this stuff. It really makes this stuff pretty easy http://www.ibatis.com/. I even have a small example lesson showing it in use (although it needs to be updated) http://www.reumann.net/do/struts/ibatisLesson1
-- Rick
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]