I want to construct a service utilities, which will wrap the service API in the methods in this service utilities so that some service clients can use this service utilities rather than directly call my service API. In this way, I can modify my service API input/output without enforce my clients to change their code to call my service.
For now, I want to have class maybe named Proxy which will call my service directly, then I have A, B, C class, since we have different type operation and I classify them to A,B, and C, each of them have one Proxy, then I will have some methods in my class A, so all my methods in class A should call proxy.methods(), but some methods may need to use methods in B or C, what's the best pattern should I do? How should I construct my code? Thanks a lot!
<code>
class A {
Proxy proxy;
// directly call proxy, then my method in A may too long, cause I
// need to call several service API
public Response Method(Request) {
proxy.method1(request);
proxy.method2();
...
}
//put method in B then call B method, but I want my A,B,C to be parallel, will this way confusing people? not a good code structure?
public Response Method(Request) {
B b = new B();
//do some logic
b.method();
}
}
class B {
Proxy proxy;
method(){
proxy.method1(request);
proxy.method2();
}
}
class Proxy
{
method1();
method2();
}
</code>
Aucun commentaire:
Enregistrer un commentaire