Bertrand Delacretaz wrote:

Le Lundi, 24 nov 2003, à 21:05 Europe/Zurich, Upayavira a écrit :

...From looking at the BeanShell docs, the Java is definitely 'scripted' java, and lacks Java's object orientedness...


But what about this example from the BeanShell docs:

buttonHandler = new ActionListener() {
    actionPerformed( event ) {
        print(event);
    }
};

button = new JButton();
button.addActionListener( buttonHandler );
frame(button);

A new behaviour for ActionListener is indeed created in a script.
Isn't this a good example of object orientedness, do you have a counterexample?

Yup. But I can't code a class called User, and then invoke it with 'new User()', I have to do it inline.


I guess I could do:

newUser() {
   user = new Object() {
       setUsername(username) {
           this.username = username;
        }
        validatePassword(password) {
        ...etc
    }
}

And then do:
myUser = newUser();
myUser.setUsername("upayavira");
if (myUser.validatePassword("xyz")) {
 cocoon.sendPage(".....");
} else {
  ...
}

Then I've effectively created a class. But it seems a bit around the houses to me.

Regards, Upayavira



Reply via email to