Your user interface should be designed with the expectation of future functionality enhancements, and it should establish a framework that will support this with minimal disruption to the users when this occurs.

So action are the best I think.

Or have I a wrong vision?

thanks, Kim

Programming today is a race between Software Engineers striving to build bigger and better idiot-proof Programs, and the Universe trying to produce bigger and better idiots.<br />So far, the Universe is winning!

Jeffry Kristianto Yanuar

Ranch Hand

Posts: 759

posted 8 years ago

I think most of the candidates use ActionListener. You just decide how to use the ActionListener.

I implement inner classes that implements ActionListener such as BookButtonListener, SearchButtonListener, ExitButtonListener, etc. Judging from its name, you can figure out what the functionality of these classes.

Originally posted by Jeffry Kristianto Yanuar: I think most of the candidates use ActionListener. You just decide how to use the ActionListener.

I implement inner classes that implements ActionListener such as BookButtonListener, SearchButtonListener, ExitButtonListener, etc. Judging from its name, you can figure out what the functionality of these classes.

Thanks for the reply. I use the same kind of namingconvention as you, but I never user inner classes. A always create a new class/file. This is my personnal favor, but I don't know if there is another reason to use inner classes or not.

Greetz, Kim

Programming today is a race between Software Engineers striving to build bigger and better idiot-proof Programs, and the Universe trying to produce bigger and better idiots.<br />So far, the Universe is winning!

Alecsandru Cocarla

Ranch Hand

Posts: 158

posted 8 years ago

I use actions as much as I can. They are easier to maintain.

You can set the same action for more components (e.g. a button and a menu item). You can do the same thing with ActionListeners, but in this case you cannot create anonymous classes, you have to create a new listener class for each action.

You can already set from the action the name of the action, the mnemonic and the accelerate key (if any). So you don't have to define these for every button.

For me, this leads to much clearer code (having everything in the same place). The performance hit... what performance hit when you only have something like 3-4 actions in the whole application?