Next: , Up: Possible Events Multiplexing Sensor Inputs   [Contents]

2.5.1 Inevitable Events versus Optional Events

The Dezyne interface keyword inevitable means that a specified event (i.e., out function) will always eventually happen asynchronously, unless something in your logic always happens to prevent the specified event – for example a timer that never gets set during execution, or that always gets canceled before it can time out. The keyword optional means that the event might or might not ever happen asynchronously. In the practical world, nothing asynchronous always happens in a system’s lifetime: not every burglar alarm gets tripped, not every email gets eventually delivered, not every transaction eventually succeeds, not every reptile species is eventually wiped out by a meteor or asteroid strike. Thus “optional” perhaps more often models the real situation than does “inevitable”. So when and why would we ever use “inevitable” in a model?

In sum, if you care about the system’s behaviour when an event goes unheeded essentially forever, or when an awaited event still hasn’t occurred long after you expected it, then use “optional”, for example for a half-entered passcode. Otherwise, “inevitable” is simpler and will usually test the system’s logical completeness and correctness well enough.

When you use “optional”, a rule of thumb might be to push down optional behaviour as low as possible in the system, or equivalently as close as possible to the hardware on which the system runs or depends.