Overview: Controller class (and its Activity), Dialer Class (and its StateMachine), Number class

Gallery
Tutorial
This is a rather busy diagram, for more complex that I would usually recommend, but it offers an overview of the entire mini system we'll be investigating, and also helps support the related screencast video. Don't fear, we are going to break it down bit by bit:
Click on the image to view it full size
Let's start at the "bottom" of the class/part hierarchy. The name Number is chosen for a class that manages a list of digits represented as:
n : int[0..*] {ordered,nonunique}
It also has the following operations:
  • isValid():Boolean: Whether we have enough numbers to be a valid phone number. In this simplified demo here we are going to assume that 4 digits is enough (to save time) and perform no further checking. The method is an OpaqueExpression of the same name in the BeanShell scripting language.
  • append(n:int): Adds another digit to 'n'. This will use an Activity as method that we'll explore in detail later.
  • print(): Prints the current list of 'n' to the simulation terminal window using an OpaqueBehavior in BeanShell.

A number:Number[1] is managed by a Dialer class, which has our main StateMachine of interest as classifier behavior. It has an operation digit(n:int) we'll be using to help trigger Transitions.

NB: The digit(n:int) deliberately does not have a method assigned, otherwise an AcceptEventAction or AcceptCallAction can't catch a matching CallEvent!

It also has an owned behavior for printing digits to the simulation terminal.

And we need a Controller to coordinate everything, with an Activity of the same name as its classifier Behavior. It has some owned Behaviors we'll look at in more detail next, but for now, note that it not only coordinates dialing, it can also react to an additional Signal Connect. Clearly, however, we don't want to connect unless the number dialed so far is valid, which its Behavior knows how to handle using guards.

We're going to work our way up from the simpler lower-level Activities to place them in context, as shown next

Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)