//
you're reading...
HCI

[UI Basics] Callback and programming models for interactive applications

What is a callback?

A callback is an application’s procedure registered for certain events. When these events occur, they are passed to and processed by the callback.

Background

According to the HCI book, there are two programming models for building interactive applications: read-evaluation loop and notification based.

  • Read-evaluation loop: the application takes in all the events passed over from the server, and employs certain mechanism (e.g., a switch statement) to process these events and decide what actions should follow.
  • Notification based: the handling of events is partially outsourced to a notifier. The application first registers with the notifier about 1) what events it is interested at, and 2) for each of these events, what callback is associated. Then the notifier simply monitors events passed over from the server, sort them and pass the handles to different callbacks accordingly.

Read-evaluation loop can be cumbersome to program with as one is totally responsible for receiving, identifying and responding to all the possible events coming to the application. With notification based, this job is mostly taken over by the notifier. But the downside is the application – unlike in the case of read-evaluation loop – doesn’t have a direct control over events that come to it. More communication is required between the application and the notifier.

Advertisements

About Xiang 'Anthony' Chen

Making an Impact in Your Life

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Twitter Updates

%d bloggers like this: