Agents and event-driven programming in Eiffel

Bertrand Meyer closes laser with a session on Eiffel. See also the first four lectures on Eiffel.

The most traditional form of event-driven programming is input-output.

It used to be the case that the program drives the user “please input your value now”. Nowadays the user is in charge “when a user presses a button, execute that action” A typical pattern is observing a value, between a subject and observer of publisher and subscriber.

Some events are characterized just by the fact of their occurrence. Others (like a mouse click at position x,y) have arguments. A traditional architecture solution is obviously the Observer Pattern. Bertrand remarks that Martin Odersky has written a paper explaining why this pattern should be depricated. Martin summarizes this paper by saying that higher level dataflow is better.

Bertrand argues that another disadvantage of the observer pattern is that it is impossible to generalize it and this makes reuse hard. To do so we need the power to abstract. To be practical, we need triples(event type, context, action) instead of pairs (event type, action) A context is an object for which an event is interesting (like a particular button) Event type-context-action tables can be implemented, for instance, as hash tables. In Eiffel, this is implemented with agents: agents are objects encapsulating behavior.

The result of this is that we now have two actions:

  • Subscribers (observers) subscribe to events
  • The publisher triggers an event
Bertrand ends with a very funny remark: Microsoft Word marks multiple inheritance as a spelling error! Bertrand states that the C# language designers must have been talking to the Word team 🙂 But in reality, so not believe this, multiple inheritance is not the work of the devil, it can be extremely useful.

This concludes my live blogging of laser, but I will be back very shortly: in two weeks with live blogs of ICSM 2012.

This post was visited 119 times.


  1. Katrin

    being a natural language processing person, I am really looking forward to your summary of Lori Pollock’s talk at ICSM – your blog is awesome 😉

    1. Felienne (Post author)

      Thanks! If you have more requests, let me know 🙂

Comments are closed.