java - use EventObject.getSource in Actionlistener -
I am restructuring some code for assignment - currently there are lots of buttons and menus in the scene and an action listener Which decides that using Event.getSource (), people from what I've read feel that it would be better for each GUI component to become its action listener, perhaps by some kind of factory. However, besides cleaning the code, what some other benefits does it mean - does not it mean that too many objects will be on the heap and can its performance be affected?
Thanks,
Aly
-
Earlier this code runs slightly faster.
-
The second increases the maintenance and expansion of your code. If you want to add a new component, you do not need to modify existing methods.
Methods, and hand-held remittances are necessary for the use of some types of switch mechanisms to isolate different components. Go, whose incidents you are handling. The system is better for you to do this. The possibility of error in this switch structure and difficult to maintain is because the program increases. Leave the system dispatch.
Source:
Comments
Post a Comment