Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
The popularity of object-oriented programming led to In synchronous event delivery the notifier blocks exe-
the development of systems that are no longer strictly hi- cution until the dispatched notification for an event is pro-
erarchical. Message passing, a core concept in object- cessed by all interested parties. Notifications are dispatched
orientation, does not demand hierarchical “use” relation- sequentially; the control flow is transferred to each of the
ships among objects. Low coupling can be achieved by con- recipients in turn and finally returns to the notifier.
sidering at least some objects as highly autonomous entities To provide an example of synchronous event delivery,
capable of reacting to notifications about changes in their we describe the Model-View-Controller (MVC) pattern [4]
environment and broadcasting such notifications to indicate in desktop GUI programming. We frequently encountered
their computational progress. this pattern in our empirical study.
Systems based on the concept of a control flow hierarchy The MVC pattern specialises the more general Observer
require their replaceable parts to fit predefined utility crite- [7] design pattern and is found in most GUI frameworks.
ria. For example, a module’s interface describes its role Two sources of events exist in GUI programming:
in the system based on its offered abstract operations. In
• user actions, such as key strokes or mouse movements,
event-driven systems, on the other hand, the focus lies on
and
specifying communication protocols. The exact purpose of
each communicating part remains unknown until late im- • application-generated events, such as requests to re-
plementation or deployment. This feature is particularly paint a screen region.
advantageous in environments where only a small subset
of requirements can be captured initially. Some examples Typically, a GUI framework translates primitive in-
include put events into semantically richer events, such as selec-
tion changes, enablement/disablement of widgets, button
• object-oriented frameworks, whose success depends presses, scroll bar movements, and many more. The pro-
on their ability to become customised for particular us- cessing of these events is, in turn, application-specific.
age contexts and to accept third-party contributions, Events are delivered synchronously. It is natural given
a single interacting user with a single set of input/output
• enterprise information systems, in which business re-
devices. Events created by the windowing system and those
quirements may change frequently after the initial
created by an application are dispatched and processed in
release and which must integrate with pre-existing
the same execution thread. Therefore, an application must
legacy software,
handle them without delay and delegate any long-running
• inter-organisational systems, which have to be admin- operations to another thread.
istered and extended decentrally due to the constrained Furthermore, the MVC pattern encourages application
availability of processed (business-critical) informa- programmers to define their own event types based on the
tion. needs of an application. Classes in the model role represent
data objects and dispatch notifications to controller classes
Apart from the improved extensibility, event-driven systems whenever a change occurs in the data. A controller reacts
may also offer better scalability than their hierarchically to such notifications by updating one or more view objects.
Asynchronous event delivery means that an event source 4. Exception propagation during event han-
may proceed with execution immediately after dispatching dling
an event without waiting for the completion of its process-
ing. Asynchronous schemes are supported by multithread-
An exception which occurs in a hierarchically structured
ing and explicit event queues. Implementations often also
system in response to a requested operation is naturally
support event persistence, routing and prioritisation.
propagated to the operation’s invoker (Section 2.2). This
Exemplarily, we consider an enterprise message bus im-
is not true for exceptions raised during event processing in
plemented using Java Message Service [10] and its rela-
an event-driven system. Apart from implementation diffi-
tionship to service-oriented architectures (SOA). SOA are
culties, such as the possible lack of a back-reference from
a modern approach to structuring enterprise applications
an event handler to an event issuer, more general problems
based on the following principles:
emerge.
• isolate business functions from execution contexts, We noted earlier that the flexibility of an event-driven
system comes from decoupling the event producers and
• publish information about these functions using direc- consumers. However, the premise of any exception prop-
tory services, and agation is that the recipient of a forwarded exception can
• provide access with standardised, implementation- better decide about the required actions than the forwarder.
neutral protocols. No general argument can be made in favour of propagating
an exception from an event handler to its issuer. Unfor-
The main benefit of adhering to SOA is the ability to tunately, this is the only kind of propagation supported by
quickly compose enterprise information systems (EIS) of mainstream programming languages.
fine-grained building blocks of business logic. It is an Existing advice available to developers of event-driven
attractive alternative to the integration of earlier, shrink- systems concerns whether or not to propagate exceptions
wrapped, coarse-grained products of ERP software vendors. from event handlers to their invokers. Two basic approaches
Basic SOA focuses on decomposition of applications exist, which we discuss in context of the Observer pat-
into services usable according to a request/response model. tern. The notified objects must provide a no-throw guaran-
However, more advanced SOA concepts provide for event- tee [22]. Alternatively, they may only supply limited failure
based communication among services. They promise eas- information by throwing some generic exception.
ier integration of disparate (and distributed) legacy systems,
better performance (when compared to polling), traceabil- 4.1. Providing a no-throw guarantee
ity, and load balancing. Meanwhile, production-quality
open source messaging frameworks are available that sup- The implementor of a notifier may decide that the noti-
port event-driven programming in the EIS context [9]. On- fied objects must not throw any exceptions. This approach
going standardisation activities (e.g., WS-Notification [15]) appears attractive as it frees her from any exception han-
also confirm its broad relevance. dling responsibilities. However, it requires that the full
The Java Message Service [10] is a vendor-specific stan- information necessary for exception handling be available
dard by Sun Microsystems related to event-driven architec- to the notified object. It also assumes that any constraints
tures. It specifies a programming interface for server-side on the behaviour of the notified object do allow appropri-
Java applications which allows creating, sending, receiving ate exception handling. While the first requirement is self-
and reading messages. Implementations with functionality evident, the latter needs further elaboration.
dictated by JMS are provided by various vendors of enter- As an example, consider the notification mechanism in
prise middleware. event-driven GUI programming explained in Section 3.1.