javadesign-patterns

Design pattern for converting one model to another model


Basically, I have a number of objects in my application and I have to convert them to another third party objects before sending the request. On receiving the response I have to convert these objects back to objects supported by my application.

What pattern can I use for converting one model object to another in Java?


Solution

  • Either Adapter or facade pattern should solve your problem:

    Adapter: http://www.youtube.com/watch?v=TriX8OiEhOU

    Facade: http://www.youtube.com/watch?v=WLjvNpP6yeQ