Company Ghost Story 公司鬼故事 15

contents

  1. 1. Redundant Debug Message
  2. 2. Naming
  3. 3. Inheritance
  4. 4. String Equal
  5. 5. Key in Condition
  6. 6. Out-of-Knowledge in Library
  7. 7. Over-overloading for Lambda
  8. 8. Oversize
  9. 9. Missing Else
  10. 10. OK, then Action
  11. 11. Listener
  12. 12. Time-consuming Message
  13. 13. Time-consuming Render
  14. 14. Crazy UI Design

Redundant Debug Message

1
2
3
class Placement {
Image image = new BufferedImage(1024, 768); // unused
}

Naming

1
2
class Colorizer { setDrawDevice(Device), removeDrawDevice(Device)}
// setDisplay(Device, boolean)

Inheritance

1
2
class XXXPanel { Panel getPanel(); }
// why not extends Panel

String Equal

1
2
if (input.contains("yes"))
// ???, equals???

Key in Condition

1
2
3
4
5
6
7
void drawTick(Color axisColor) {
if (color.equals(Color.RED))
dx++;
else
dy++;
}
// Color as key? why not pass enum Axis

Out-of-Knowledge in Library

1
2
3
4
class AbstractTableViewRenderer {
EDA_DIE_ONLY_RENDER dieRender;
}
// don't put your shit on UI library

Over-overloading for Lambda

1
2
3
4
5
6
class AbstractTableView {
public void with(MouseInterface)
public void with(TextInterface)
public void with(IconInterface)
}
// overloading is not for heterogeneous

Oversize

1
2
long degree; // [0, 360)
// oooooooooooooover-size

Missing Else

1
2
3
4
if (geom instanceof Circle) { renderAsBall((Circle) geom); }
else if (geom instanceof Oblong) { if (type == ball) renderAsCylinder(geom);} // new feature
else renderAsPoly(geom.toPoly());
// fuckup, default as polygon, where is your else
1
2
3
4
setProperty(Object dbo, String name, Object val) {
if ("group".equals(name)) Group.set(dbo, val);
}
// where is your else and exception

OK, then Action

1
2
3
4
buttonOK.setOnAction(e -> apply());
void apply() {...; rebuildModel();}
slider.setOnChange(e -> rebuildModel()); // new feature
// our performance is gone by you

Listener

1
2
3
4
void setDisplay(...) {
fireProperytChange("SetDisplay");
}
// ... property is display, not the method name

Time-consuming Message

1
2
Object.requireNotNull(number, "The number is not illegal by " format + " with" + ... context);
// don't compose the error message, construct it on demand.

Time-consuming Render

1
2
3
4
5
class ListRenderer {
void render(ListItem e) {
ImageIO.read(getImagePath(e.getValue().getType()));
}
}

Crazy UI Design

1
2
3
4
5
6
7
|------------------|
| Chooser |
+------------------+
| [ComboBox] | # 10^6 objects
| [Cancel] [OK] |
+------------------+
# tell me, how do you pick