The Ordering model demonstrates the use of Alf as the action language within an executable model using State Machines. It includes the following diagrams:

  • Order Classes – A Class diagram of an Order consisting of multiple OrderLineItems, placed by a Customer, which may be paid using a CreditCard.
  • Order_Behavior – A State Machine diagram of the active Behavior of an Order.
  • CreditCardCharge_Behavior – A State Machine diagram of the active Behavior of a CreditCardCharge (this is just a stub for testing purposes).
  • Customer_Behavior – A State Machine diagram of the active Behavior of a Customer (this is just a stub for testing purposes).
  • Test – A Class diagram of a simple Test Class with a classifier behavior that acts as a test driver.

Alf is used to define the behavior of all Operations in the Order Classes model, entry Behaviors in all the state machines and the classifier behavior for Test. To view any of the Alf code, open the Alf editor window (select Windows > Alf) and then select the desired Operation, entry Behavior or Activity. The Alf code will appear in the window.


To run the test


  1. Select Simulation > Run on the class Test.
  2. Set the Animation speed to maximum (even if it looks like it is already at maximum, make sure the slider is all the way to the right).
  3. Click on the Start button.
  4. When the run pauses, select Order_Behavior in the Sessions tab.
  5. Select SubmitCharge under Trigger.
  6. Select CreditCardCharge_Behavior in the Sessions tab (this State Machine should be in the State Verifying at this point).
  7. Select either ChargeApproved or ChargeDenied under Trigger.
  8. Select Order_Behavior in the Sessions tab.
  9. If ChargeDenied, then Order_Behavior should be in State Payment Not Approved. Select either SubmitCharge or OrderCancelled under Trigger. If SubmitCharge, go back to step 7.
  10. If ChargeApproved, then Order_Behavior should be in State Awaiting Delivery. Select OrderDelivered under Trigger.