Rom*_*man 5 java oop refactoring
目前,我有以下代码(而且我不喜欢):
private RenderedImage getChartImage (GanttChartModel model, String title,
Integer width, Integer height,
String xAxisLabel, String yAxisLabel,
Boolean showLegend) {
if (title == null) {
title = "";
}
if (xAxisLabel == null) {
xAxisLabel = "";
}
if (yAxisLabel == null) {
yAxisLabel = "";
}
if (showLegend == null) {
showLegend = true;
}
if (width == null) {
width = DEFAULT_WIDTH;
}
if (height == null) {
height = DEFAULT_HEIGHT;
}
...
}
Run Code Online (Sandbox Code Playgroud)
我该如何改善?
我对引入一个包含所有这些参数作为字段的对象有一些想法,然后也许可以应用构建器模式。但是仍然不清楚如何实现该目标,我不确定是否值得这样做。还有其他想法吗?
| 归档时间: |
|
| 查看次数: |
1772 次 |
| 最近记录: |