Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] User interface code smell and update of the wiki

In fact you are talking about model-to-view and view-to-view
synchronisations where data bindings should indeed replace listeners (as
promoted by all modern GUI toolkits).

Blob listeners are not part of that. They are elements of
controllers/presenters/whatever that receive events produced by widgets
to then produce actions/commands that modify the model.



> I'd argue that listeners themselves are an antipattern.
>
> - They risk memory leaks if they aren't explicitly removed.
> - They don't have inherent flow control, and can introduce performance
> problems when things change more rapidly than those changes need to be
> consumed.
> - They duplicate business logic between whatever code initializes an
> observer's initial state and whatever updates that state in the listener.
> - The set of things that are listened to need to match the set of
> dynamic data that is accessed within the listener. If they get out of
> sync, it introduces stale data bugs. Such bugs are hard to test for
> and easy to create.
> - Most listeners are synchronous, which creates all sorts of special
> cases when they invoke methods that reach back and access the code
> that is invoking the listener.
>
> Now that we have several good models for reactive programming (
> databinding's SideEffect class and tracked getters or one of the
> various FRP libraries ), there's no need to use listeners at all
> anymore except within the implementation of said libraries.
>
>


Attachment: signature.asc
Description: OpenPGP digital signature


Back to the top