考虑以下界面.
public interface ThirdPartyApiHandler {
public OperationResult doOperation(OperationInput input);
public static class OperationResult {
//members of OpeationResult. metrics after file processing
private int successfulRecords;
private int failedRecords;
}
public static class OperationInput {
//implementations call third party API to process this file.
private String inputBatchFile;
}
//Constant which would be same across all implementations.
public static final int GLOBAL_CONSTANT = 1;
}
界面设计不好吗?
> OperationResult和OperationInput定义为静态类.它们仅用于实现而不是其他任何地方.我在这里看到的优点是 – 我不必为这两个类创建单独的文件.他们也获得了父类的命名空间.
>我已阅读有关常量接口的信息.但在这种情况下,我在普通接口中定义常量,这些常量在所有实现中都必须相同,并且将在这些实现中使用.
我是第一次使用这种模式,所以想得到建议.