Q:

Which of these two examples is a better code design?

Example #1
public void mouseClicked(MouseEvent e) {
    if (isShowParameters)
       isShowParameters = false;
    else
       isShowParameters = true;

    ParametersWindows.getInstance().setVisible(isShowParameters);
}  

Example #2
public void mouseClicked(MouseEvent e) {
    isShowParameters = !isShowParameters;
    ParametersWindows.getInstance().setVisible(isShowParameters);
}

A:

The second one is more clear and logical.

A:

I prefer isShowParameters = !isShowParameters; because it's shorter.  Shorter programs are easier to understand and maintain.  But what is with your huge clump of unmatched right brackets?  That seems like a bad coding style.

A:

ParametersWindows.getInstance().setVisible(!isShowParameters);

;)
Update
Only works if you don't need the field itself to be updated.

