Martijn Dashorst wrote:
On Mon, Jun 16, 2008 at 3:48 PM, Matthijs Wensveen <[EMAIL PROTECTED]> wrote:
A little off-topic: It scares me a little when core developer make bold
statements like: "setters are evil" and "I wouldn't mind final was the
default in java". Maybe I'm just being paranoid here...
Why? Are we not allowed an opinion?
Why off-course! Am I not allowed to be scared? ;P
And from an OO point of view, I
can see how setters break encapsulation: they expose the internal
state of an object. In the case of setVisible this is exacerbated
because the semantics of the following are vague:
Label l = new Label("l", "foo") {
@Override boolean isVisible() { return false; }
};
l.setVisible(true);
add(l);
So either you'd want final to be the default, or you'd consider
setters evil. :-D
Hehe. Maybe in that case you should override setVisible as well to throw
an UnsupportedOperationException?
I disagree that you expose internal state. It's hardly internal when
there is a public setter. But I agree that it is often very useful to
override the getter (isser for booleans?) when there is a hard
dependency between the component visibility and some other state. As I
said: it's good to have choice.
Martijn
--
Matthijs Wensveen
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]