[josm-dev] Spaghetti code

Igor Shubovych igor.shubovych at gmail.com
Wed Feb 4 22:53:28 GMT 2009


Ladies and gentlemen,

I really do not want to abuse anybody, but ... this is spaghetti code.
...Almost everywhere in JOSM.

Most fields which represents GUI components (labels, text fields buttons) in
panels and dialogs are public or have package visibility level.
E.g.
public class PleaseWaitDialog {
    public final JLabel currentAction = ...
    public final BoundedRangeModel progress = ..
    public final JButton cancel = ...
    ...
}

And they are used directly in many program parts.
E.g.
Main.pleaseWaitDlg.currentAction.setText(tr("Contacting Server..."));

Now if I need to change some basic logic, I have to fix ~55 occurrences in
program. Arrrr.

Please in future, while designing some new dialog or panel, consider most
fields private, and do some easy API to work with fields:
E.g.
public class PleaseWaitDialog {
    private JLabel currentAction = ...
    private BoundedRangeModel progress = ..
    private JButton cancel = ...
    ...
    public void setActionName(String text) {
    }

    // And so on
}

And yet a bit. Why so overfinalized? Could anybody explain?

Best regards,
Igor Shubovych



More information about the josm-dev mailing list