• Post Reply Bookmark Topic Watch Topic
  • New Topic

Design Question on the proxy and adapter pattern  RSS feed

 
saloni Bachchan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need some help on designing.

I have a server which exposes some interface and implements it .The implentation has 2 methods.
Each of these return a List of different objects.so method 1 returns data in the form of List<A> objects ,Method 2 returns data in the form of List<B> objects where A and B are my data model objects.
I have written a proxy which exposes the same interface as my server.The client makes calls on my proxy and the proxy forwards the calls to the server and gets back the data as List<A> or List<B> depending on what the client has asked for.Now the requirement is that the client does not want the data in the List<A> or list<B> formats.The client wants the data in it's own format which is a TupleMap.So the client will ask for A or B's data but it wants us to return it in the tuplemap format.
What I did was I implemented a simple class called tuple map transformer.The class has 2 methods .Method1 takes in List<A> objects and method2 takes in List<B> objects.Both return a TupleMap.
Note that the logic to convert A to tuplemap and B to tuplemap is different ,hence two methods.
Now the client first calls the proxy and then calls the transformer to get the data in the format it requires.
I think there is a better way to implement this.Adapter pattern?I am not sure.Can someone please help.
It's urgent

Thanks
 
saloni Bachchan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help with the below query
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as “urgent” here.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saloni Bachchan wrote:Please help with the below query
Below?

Read this.
 
saloni Bachchan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologies.I meant above query.
 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saloni Bachchan wrote:I think there is a better way to implement this.Adapter pattern?
Yes, or else a facade. But there's no reason the implementation couldn't make use of your transformer utility under the hood -- that's pretty much how we implement an adapter at my shop.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!