以下は私のインターフェースです -
public interface IClient {
public String executeSync(ClientInput input);
}
これは私のインターフェースの実装です -
public class TestingClient implements IClient {
@Override
public String executeSync(ClientInput input) {
}
}
今、私はTestingClient
このようなインスタンスを取得するファクトリを持っています -
IClient client = TestingClientFactory.getInstance();
ここで、顧客はパラメーターを受け入れるexecuteSync
my のメソッドを呼び出します。以下は のクラスです。TestingClient
ClientInput
ClientInput
public final class ClientInput {
private Long userid;
private Long clientid;
private Long timeout = 20L;
private boolean debug;
private Map<String, String> parameterMap;
public ClientInput(Long userid, Long clientid, Map<String, String> parameterMap, Long timeout, boolean debug) {
this.userid = userid;
this.clientid = clientid;
this.parameterMap = parameterMap;
this.timeout = timeout;
this.debug = debug;
}
... //getters here
}
したがって、顧客が のexecuteSync
メソッドを呼び出すと、このようにパラメータTestingClient
を作成しClientInput
、ファクトリを使用して のインスタンスを取得し、TestingClient
それに応じて executeSync メソッドを呼び出します。
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("attribute", "segmentation");
ClientInput input = new ClientInput(109739281L, 20L, paramMap, 1000L, true);
IClient client = TestingClientFactory.getInstance();
client.executeSync(input);
問題文:-
ClientInput
これは、上記のようにパラメーターを作成してexecuteSync
メソッドに渡す正しい方法ですか?- ClientInput にはすでに Long 型の引数が 3 つあるため、他の開発者には、どのフィールドがどの位置にあるのかが明確ではない可能性があります (特に長い夜の間は...)。これを回避する方法はありますか?
- より多くの入力が必要な場合は、コンストラクターの宣言が長くなります。どうすればこの状況を克服できますか?