'. '

RequestResponse

From APIDesign

Revision as of 19:54, 25 June 2008 by JaroslavTulach (Talk | contribs)
Jump to: navigation, search

Response Reply

Design pattern that solves the problem of growing parameters and return values from API methods. Beyond its basic purpose, it can help with delivering multiple results and providing the results in an incremental way, one by one. It also helps a lot with ability to cancel a computation in the middle.

public interface ComputeSomething {
    public void compute(Request request, Response response);
 
    public static final class Request {
        private Request() {}
 
        public int getArg1();
        public String getArg2();
    }
 
    public static final class Response {
        private Response() {}
 
        public void addResult(int r);
        public void addResult(String[] arr);
    }
}
Personal tools
buy