2022-06-19 工作應用/鬼故事 Company Ghost Story 公司鬼故事 15 contents 1. Redundant Debug Message2. Naming3. Inheritance4. String Equal5. Key in Condition6. Out-of-Knowledge in Library7. Over-overloading for Lambda8. Oversize9. Missing Else10. OK, then Action11. Listener12. Time-consuming Message13. Time-consuming Render14. Crazy UI Design Redundant Debug Message123class Placement { Image image = new BufferedImage(1024, 768); // unused} Naming12class Colorizer { setDrawDevice(Device), removeDrawDevice(Device)}// setDisplay(Device, boolean) Inheritance12class XXXPanel { Panel getPanel(); }// why not extends Panel String Equal12if (input.contains("yes"))// ???, equals??? Key in Condition1234567void drawTick(Color axisColor) { if (color.equals(Color.RED)) dx++; else dy++;}// Color as key? why not pass enum Axis Out-of-Knowledge in Library1234class AbstractTableViewRenderer { EDA_DIE_ONLY_RENDER dieRender;}// don't put your shit on UI library Over-overloading for Lambda123456class AbstractTableView { public void with(MouseInterface) public void with(TextInterface) public void with(IconInterface)}// overloading is not for heterogeneous Oversize12long degree; // [0, 360)// oooooooooooooover-size Missing Else1234if (geom instanceof Circle) { renderAsBall((Circle) geom); }else if (geom instanceof Oblong) { if (type == ball) renderAsCylinder(geom);} // new featureelse renderAsPoly(geom.toPoly());// fuckup, default as polygon, where is your else 1234setProperty(Object dbo, String name, Object val) { if ("group".equals(name)) Group.set(dbo, val);}// where is your else and exception OK, then Action1234buttonOK.setOnAction(e -> apply());void apply() {...; rebuildModel();}slider.setOnChange(e -> rebuildModel()); // new feature// our performance is gone by you Listener1234void setDisplay(...) { fireProperytChange("SetDisplay");}// ... property is display, not the method name Time-consuming Message12Object.requireNotNull(number, "The number is not illegal by " format + " with" + ... context);// don't compose the error message, construct it on demand. Time-consuming Render12345class ListRenderer { void render(ListItem e) { ImageIO.read(getImagePath(e.getValue().getType())); }} Crazy UI Design1234567|------------------|| Chooser |+------------------+| [ComboBox] | # 10^6 objects| [Cancel] [OK] |+------------------+# tell me, how do you pick Newer 維護作業 Older 規劃 ‧ 生活