Login | Register
My pages Projects Community openCollabNet

Discussions > Notification of Issues > [argouml-issues] [Issue 6524] New - Remove 11 Blob listeners [patch]

argouml
Discussion topic

Back to topic list

[argouml-issues] [Issue 6524] New - Remove 11 Blob listeners [patch]

Author arnob
Full name Arnaud
Date 2017-01-09 04:17:04 PST
Message http://argouml.tigri​s.org/issues/show_bu​g.cgi?id=6524
                 Issue #|6524
                 Summary|Remove 11 Blob listeners [patch]
               Component|argouml
                 Version|current
                Platform|All
                     URL|
              OS/Version|All
                  Status|NEW
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|PATCH
                Priority|P3
            Subcomponent|GUI
             Assigned to|bobtarling
             Reported by|arnob






------- Additional comments from arnob at tigris dot org Mon Jan 9 04:16:40 -0800 2017 -------
Hi guys,

Sorry in advance for the long text.

We are researchers in software engineering that currently work on user interface
(UI) bad coding practices. We are studying UI listeners, in particular listeners
that manage several widgets, like the following listener extracted from ArgoUML:

public void itemStateChanged(ItemEvent e) {
    Object src = e.getSource();
    Fig target = getPanelTarget();
    if (e.getStateChange() == ItemEvent.SELECTED
        && target instanceof FigText) {
    if (src == fontField) {
        setTargetFont();
    } else if (src == sizeField) {
        setTargetSize();
    } else if (src == styleField) {
        setTargetStyle();
    } else if (src == justField) {
        setTargetJustification();
    } else if (src == textColorField) {
        if (e.getItem() == getCustomItemName()) {
            handleCustomColor(te​xtColorField,
                    "label.stylepane.cus​tom-text-color",
                    ((FigText) target).getTextColor());
        }
        setTargetTextColor();
    } else {
        super.itemStateChanged(e);
    }
    }
}

In such listeners, the source widget is identified using if/switch statements.
Thanks to empirical studies we have indications that such a practice has a
negative impact on the code quality. We call UI listeners that control three or
more widgets, Blob Listeners (see this PDF document for more details:
https://hal.inria.fr​/hal-01308625v2/docu​ment).

We identified in ArgoUML 11 instances of the Blob listener for which we have a
refactoring solution. This patch removes these 11 Blob listeners by splitting
them into atomic UI listeners (i.e. they manage a single widget). We manually
tested ArgoUML for any regression. The new code is less complex in terms of
cyclomatic complexity (CC) and lines of code (LoC): the new code has -35 LoCs
and -54 of CC on the refactored files (according to Sonar analyses).


Complementary to this path, we have several questions for the ArgoUML's developers:

1/ Do you think that coding UI listeners that manage several widgets is a bad
coding practice?


2/ Do you think that the threshold of three or more widgets per listener
relevant for characterising a Blob listener?


3/ Do you consider the refactored code suitable for removing Blob listeners?


4/ Do you have any idea of the reason of the presence of Blob listeners in the code?
For example, lack of anonymous functions (aka lambdas) in Java 7 (and previous
JDKs)? Mutltiple developers? etc.

5/ Do you have suggestions about other bad user interface coding practices? This
can concern controllers, commands, GUIs, widgets, data bindings, GUI testing, etc.


-- Arno

« Previous message in topic | 1 of 2 | Next message in topic »

Messages

Show all messages in topic

[argouml-issues] [Issue 6524] New - Remove 11 Blob listeners [patch] arnob Arnaud 2017-01-09 04:17:04 PST
     [argouml-issues] [Issue 6524] Remove 11 Blob listeners [patch] arnob Arnaud 2017-01-09 04:17:12 PST
Messages per page: