Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [riena-dev] Deprecate IActionListener.addListener(Object, String) ?

Hi Elias,
those methods are very convenient when implementing application logic eliminating the need for unnecessarily verbose and hard-to-read innner classes in many cases. You just call a beans methods. That's what a framework is all about - making programmers life easier, isn't it? BTW, i think a similar pattern is used in IComboRidget when specifying the renderingMethod parameter.
It is also more efficient using the Proxies created by the java.lang.EventHandler instead of inner classes (see class comment of java.lang.EventHandler: 
"...The reason that listeners created with EventHandler have such a small footprint is that the Proxy class, on which the EventHandler relies, shares implementations of identical interfaces. For example, if you use the EventHandler create methods to make all the ActionListeners in an application, all the action listeners will be instances of a single class (one created by the Proxy class). In general, listeners based on the Proxy class require one listener class to be created per listener type (interface), whereas the inner class approach requires one class to be created per listener (object that implements the interface)...")
A corrensponding remove method does not make too much sense as you cannot easily identify the exact instance you want to remove - instead the method signature might be changed to return the created event handler proxy: This object could then be used with the regular #removeListener method (anyway I would think that removing an action listener from a button is anything but a frequent use case in application programming - wouldn't you either throw away the controller if not used anymore or put some logic into the action listener instead of keeping adding/removing different instances?).
Cheers,
--Holger
________________________________________
From: riena-dev-bounces@xxxxxxxxxxx [riena-dev-bounces@xxxxxxxxxxx] On Behalf Of Elias Volanakis [elias@xxxxxxxxxxxxxxxxx]
Sent: Wednesday, August 12, 2009 21:08
To: Riena Developers list
Subject: [riena-dev] Deprecate IActionListener.addListener(Object, String) ?

Any objections against deprecating IActionListener.addListener(Object, String) ?

Reasons:
- it falls out of our normal style which is: addListener(Listener
listener) & removeListener(Listener listener)
- there is no corresponding removeListener(Object, String) method
- it is not used anywhere in the Riena code base
- IActionListener already has the regular addListener(lsnr) and
removeListener(lsnr) methods

IActionListener.java:
        /**
         * Add an action listener to call back. This method is equal to calling
         * #addListener(java.beans.EventHandler.create(IActionListener.class,
         * target, method))
         * <p>
         * Adding the same listener several times has no effect.
         *
         * @param target
         *            the object to notify
         * @param action
         *            the method on {@code target} to invoke
         * @see java.beans.EventHandler#create(Class, Object, String)
         */
        void addListener(Object target, String action);

Kind regards,
Elias.
--
Elias Volanakis | Technical Lead | EclipseSource Portland
elias@xxxxxxxxxxxxxxxxx | +1 503 929 5537 | http://eclipsesource.com
_______________________________________________
riena-dev mailing list
riena-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/riena-dev

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.392 / Virus Database: 270.13.58/2304 - Release Date: 08/15/09 06:10:00

Back to the top