• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

object conversion pattern

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, what is the best design approach to implement a solution that converts between various objects in different tiers... i.e. domain objects in the business tier, value objects in the data tier, DTOs in the service tier that may have different data representations of the equivalent domain objects etc.

Right now I have seen adapter approaches but this can get kludgy real quick. For instance: DAO returns value object, it gets converted into a business object by some adapter class, it is then again run through a static conversion method in a giant BusinessToServiceObjectAdapter which returns the Service Object. Usually data transformation rules are hardcoded, for instance gender property value "Male" in Business Object may need to be converted to "M" or something similar. Some automation using BeanUtils.copyProperties and such may also be used.

Another approach I have *heard* about is using a domain wide XML representation of data. Now objects in all tiers will know how to represent it's dataset in this XML structure. XSLT will be used for transformation of data using the appropriate XSD. The benefit is maintainability since transformation rules are externalized to the XSD instead of in the code.

What has been your own approach to object conversion?
[ October 22, 2007: Message edited by: Kevin Smither ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic