File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Suggest a pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Suggest a pattern" Watch "Suggest a pattern" New topic

Suggest a pattern

Ramu Nur

Joined: Aug 21, 2010
Posts: 22
I'm working on some exercises on patterns. I've a requirement wherein the request object is same for 8 methods which invoke a webserice but the response object vary. In responses, some are objects, some of boolean, some are void. The legacy webservice is designed in such a way that response depends on request xml name.

What can be a better design pattern to consider. I thought of template method, but the template method response has to be Object and I don't want to cast it back based on request name. I can have 8 methods, but is there any alternative?

Thanks in adv.
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4635

What's wrong with each method sending the request, and then just returning a different type?

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
I agree. Here's the link:
subject: Suggest a pattern
It's not a secret anymore!