You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "Roger Whitcomb (JIRA)" <ji...@apache.org> on 2017/11/07 19:48:00 UTC

[jira] [Updated] (PIVOT-1011) Move ListenerList implementations of interfaces into the interface itself

     [ https://issues.apache.org/jira/browse/PIVOT-1011?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Roger Whitcomb updated PIVOT-1011:
----------------------------------
    Attachment: 1011.diffs

The attached "1011.diffs" file shows this done for Query.java and QueryListener.java.  The "QueryListenerList" is moved from Query to QueryListener, and renamed to just "List", so the reference in Query is to "QueryListener.List" instead of "QueryListenerList", but otherwise everything else is unchanged.

So, we have "QueryListener", "QueryListener.Adapter" and "QueryListener.List" all revolving around this interface, and in the one file.

This seems cleaner to me, and better encapsulates the interface, so that changes/additions to it can all be made in one file for better consistency.  (Of course, if an interface changes, all the users would have to change too, but that would happen no matter what).

Open to feedback/criticism.  And maybe this is not really needed, but it seems a beneficial change for clarity, and the 2.1 version seems well-suited to potentially breaking changes like this (altough, as I pointed out, I don't think client code would need to be changed).

> Move ListenerList implementations of interfaces into the interface itself
> -------------------------------------------------------------------------
>
>                 Key: PIVOT-1011
>                 URL: https://issues.apache.org/jira/browse/PIVOT-1011
>             Project: Pivot
>          Issue Type: Improvement
>          Components: core-collections, core-util, web, wtk, wtk-terra
>         Environment: All
>            Reporter: Roger Whitcomb
>            Assignee: Roger Whitcomb
>            Priority: Minor
>         Attachments: 1011.diffs
>
>
> A universal paradigm in Pivot is to have a "listener" interface for a class or data structure that is used to notify listeners of changes in the class/data.  There is then an "Adapter" static class in the interface file that implements the interface with default implementations.  Then there is a very separate enclosed static class that implements the "ListenerList" interface of that listener interface.  And usually (or always) this "listener list" class is defined/used only in the class that needs to notify the listeners.  However, this class must be very parallel to not only the interface itself, but also the "Adapter" class, and yet it is in a different place.
> So, it seems somewhat reasonable to move all these "listener list" classes into the interfaces themselves, so all three related things are located in the same file.  A preliminary POC of this concept was done with "Query.java", and "QueryListener.java" and it looks good.
> This doesn't seem to require changes to client code, because the accessor methods only refer to "ListenerList<....>" and not to the listener list class itself (in order to be more general, of course), but which helps us to hide the implementing class away inside the interface.
> I will attach the diff of the POC, to hopefully make this more clear.  It may seem a somewhat nebulous concept, but the idea is to keep "like things" together for clarity.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)