我有一个客户端库,我在其中对我的休息服务进行http远程调用,然后我返回List<DataResponse>给调用我们的库的客户,我从REST服务获取响应以及任何错误,如果有任何包装DataResponse对象周围.
public class DataResponse {
private final String response;
private final boolean isLink;
private final TypeOfId idType;
private final long ctime;
private final long lmd;
private final String maskInfo;
// below are for error stuff
private final ErrorCode error;
private final StatusCode status;
// constructors and getters here
}
Run Code Online (Sandbox Code Playgroud)
这是我的ErrorCode枚举类:
public enum ErrorCode {
// enum values
private final int code;
private final String status;
private final String description;
// constructors and getters
} …Run Code Online (Sandbox Code Playgroud) 例如,我有一个构建GUI的类,一个处理GUI所有事件的类,以及包含受GUI对象(主要是滑块)影响的所有对象的主类,以及GUI类和事件类.
现在,事件类的构造函数具有GUI类和GUI所更改的每个对象作为参数.这些都是相当多的对象,所以我现在拥有的论据数量大约是8,而且还在增长.
对我的问题有一个更优雅的解决方案,30个参数根本感觉不对吗?
ps,我宁愿不合并类,因为这三个都很大,并且会使一切都变得不那么可读.