On Display Events Considered Harmful

This page takes the position that on-display events, as commonly seen in JavaScript-rendered HTML and in the construction of GUI shell applications, are 'harmful' in the sense that their potential for abuse (even when not actually abused) holds us back from achieving many beneficial UserInterface features. Further, this page explains weaker alternatives to on-display events to achieve the same features without the disadvantages or potential for abuse.

First a few working definitions:

On-display events are commonly used to refresh data, start threads or events to keep that data up-to-date, etc. Most of these uses are relatively harmless. The problem with on-display events is not their harmless uses, but rather is their potential for abuse. This is similar to how having SideEffects in functions prevents arbitrary CompileTime PartialEvaluation, or how being TuringComplete introduces complex concerns of divergence when composing programs.

I posit that all common, harmless uses may be performed without relying upon on-display events. But I'll come back to describing those alternatives, later.

Let's assume then that applications are using on-display events to their full extent, to what I consider to be abuse-cases of on-display events:

From these abuse-cases and more general principles, we can make the following observations: To these, we can add the general problems associated with constructor events (ConstructorsAreEvil).


Alternatives:


This page could use some coded examples. Things like SpaghettiCode are often in the eye of the beholder.

SpaghettiCode isn't something that can be shown in a toy example. It's a scaling problem.

When I've seen SpaghettiCode, usually I can find a way to describe why I feel it's spaghetti. Or, at least raise it as a question, such as "why did you use approach A here, but approach B here? Why not use the same; they do essentially the same thing." Or, "Why so many levels of indirection between this and this? What kind of change were you anticipating?"

But more to the point, you have to explicitly show X succeeding where Y fails if you claim something is better than something else. You cannot just rely on "trust me, I'm smart" because everybody thinks they are smart.

''I don't rely on "trust me, I'm smart". I rely on "You're smart too. Run a few example problems if you can't see it right away." The proof that on-display events contribute to SpaghettiCode simply reduces to demonstration that SideEffects and the global coupling necessary for the specified 'on-display event' to provide these SideEffects each contribute to SpaghettiCode and BigBallOfMud.


Internal Vs. External

Re: In this case non-local side-effects means any communications that affects something outside the immediate document being displayed. This includes communications with a server, but it also includes manipulations of other parts of the document. (cf. SideEffect)

But often the client and the server are a partnership. The "distance" is only an unfortunate happen-stance or condition that exists for some architectural reason. Whether we consider it "internal" or "external" is relative. It's called being flexible and adaptive. Sometimes we want to treat things as external and sometimes internal, depending on the need. It's virtualization in action.

It is 'relative' to "the immediate document being displayed". This was made explicit in the definition. A document being displayed might be a form, or even just a single checkbox inside a form. If a checkbox inside a form had an 'on_display()' event that could modify the rest of the form, or (even more global) the server, then doing so would qualify as non-local side-effects because the side-effects aren't 100% 'local' to the checkbox. Just about the only 100% local side-effect would be setting the checkbox value or stylistic options.

As far as that "partnership" goes, it is useful to model the client as providing a view of an application provided by the server, as opposed to providing the application. Why is it useful? Because thinking about views of applications allows you to model multiple views of applications, of shared views, of migrating views, of composed views, of most-recent-updated views, of zoomable views, of mashup or relational-query views (GooglifyDeepMenus), and so on. Why is that useful? Because those are GuiEngineGoals that are not being achieved in your current design. I suspect they cannot readily be achieved without restricting the role of a client in its 'partnership' with the server to providing, for example, 'just a view' of the application. (Not that maintaining views is a small challenge or anything. That's still a very significant role.)


EditText of this page (last edited June 15, 2009) or FindPage with title or text search