Event-Based Programming

Ken Webb 2010-04-01T16:37:46Z

Ted Faison is the author of the book Event-Based Programming: Taking Events to the Limit. Ted uses several related names for his approach - Event-Based Architectures (EBA) and Event-Based Programming (EBP). The approach is similar in some ways to the Xholon approach. The EBP/EBA examples are written in C#.

An EBP application includes a Builder class that centralizes the creation of instances of all the domain classes, and a Binder class that then binds instances together so they can collaborate at runtime. The intent is to minimize coupling. The Builder class has a similar functionality to the CompositeStructureHierarchy.xml file in a Xholon application. The Binder class has a similar role to the Xholon ClassDetails.xml file. EBP uses C# to instantiate objects, while Xholon typically uses a more indirect XML approach. At runtime, in both EBP and Xholon, all objects are first created, and then selected objects are bound. In both approaches, the domain classes (Java or C#) do not directly specify their interaction partners, and they do not directly instantiate their children.

Ted's website includes a tutorial on building a SystemBrowser application. The C# Builder class is:

public static class Builder
  public static Binder Binder;
  public static FormMain FormMain;
  public static FormMenuToolBar FormMenuToolBar;
  public static StatusBar StatusBar;
  public static NavigatorFolders NavigatorFolders;
  public static ContentFileList ContentFileList;
  public static void Build()
    // create all UI elements
    Binder = new Binder();
    FormMain = new FormMain();
    FormMenuToolBar = new FormMenuToolBar();
    StatusBar = new StatusBar();
    NavigatorFolders = new NavigatorFolders();
    ContentFileList = new ContentFileList();

The Xholon equivalent in a CompositeStructureHierarchy.xml file would be as follows. Xholon also requires framework classes to parse the XML and do the actual instantiation.


The EBP C# Binder class is:

public class Binder
  public void Bind()
    Builder.FormMenuToolBar.ViewIcons += Builder.ContentFileList.ShowIcons;
    Builder.FormMenuToolBar.ViewDetails += Builder.ContentFileList.ShowDetails;
    Builder.FormMenuToolBar.UpClicked += Builder.NavigatorFolders.SelectParentFolder;
    Builder.FormMenuToolBar.AddressChanged += Builder.NavigatorFolders.SelectFolder;
    Builder.NavigatorFolders.FolderChanged += Builder.ContentFileList.Populate;
    Builder.NavigatorFolders.FolderChanged += Builder.FormMenuToolBar.ShowAddress;
    Builder.NavigatorFolders.Message += Builder.StatusBar.ShowMessage;
    Builder.ContentFileList.Message += Builder.StatusBar.ShowMessage;
    Builder.ContentFileList.FolderDoubleClicked += Builder.NavigatorFolders.SelectFolder;

The Xholon equivalent in a ClassDetails.xml file would include elements such as the following.

  <port name="ViewIcons" connector="#xpointer(../ContentFileList)"/>

Xholon would also use signals, and would include code that would use the signals as method selectors. The instance of FormMenuToolBar could send a message (EBP event):

ViewIcons.sendMessage(ShowIcons, null, this);

which would be processed by the receiving ContentFileList instance:

if (signal == ShowIcons) {

The EBA/EBP approach uses Signal Wiring Diagrams to document the connections between parts. These are similar to UML 2 Composite Structure Diagrams that can be used with Xholon. Examples of Signal Wiring Diagrams are available in an article at Ted's site. Both types of diagrams show objects, points of connection between objects (ports in UML/Xholon, pins in EBP), and connections between ports or pins. Signal Wiring Diagrams also show the direction of the interaction, and the names of the signals, which in UML and Xholon are more typically shown in separate Sequence Diagrams.

A few questions I have:

return to main page