More SEQUENCE posts
July 28, 2003
Alternative Syntax

I'm thinking of implementing an alternative syntax for specifying a diagram for SEQUENCE. The current syntax is going to make it very difficult to add some of the features, such as stereotypes and method arguments in a sensible way. Here are my initial thoughts.

Simplest. Call method aMethod on object anObject.

anObject . aMethod

You can also use << and >> for methods like create.

instance.<<create>>

The spaces around the . separating the object and method names are optional. If aMethod has a return value it is shown following -> after the method name, as below.

anObject.aMethod -> returnValue

The calls made by a method are shown in it's method body, enclosed in { and }, which follows the method name, or returnValue if present.

anObject . aMethod {
  anotherObject.aDifferentMethod -> someValue
}

anObject.aMethod -> returnValue {
  anotherObject.aDifferentMethod -> someValue
}

The name of the object can be made up of three fragments. The ClassName must start with : and the stereotype must be surrounded by << and >>.

objectName :ClassName <<stereotype>>

Any combination of the fragments may be used so any of the six examples below would be valid.

objectName
objectName :ClassName
objectName:ClassName <<stereotype>>
:ClassName
:ClassName <<stereotype>>
<<stereotype>>

A quick example. This also shows the use of " to surround a names that contains spaces. The same technique is used if the class name contains spaces. As the stereotype must be surrounded by << and >> there is no need to use " in this case.

"A Student" <<actor>> enroll {
  :EnrollInSeminar <<controller>> ."wish to enroll"
}

The method name may also be more elaborate than a simple name. It can include an iteration marker *, a condition enclosed with [ and ], and arguments following the method name surrounded by ( and ).

accountBalance.*[transaction has debits]withdraw(debit amount)
Posted by Alex at July 28, 2003 09:18 PM