Thursday, 23 April 2009

Custom and Automatic Key Lettering

Shlaer-Mellor OOA uses key letters to identify various model elements. Objects and terminators (collectively known as entities) define key letters (normally an abbreviation of their names) as a unique short identifier. Key letters can be used to identify entities within Action Language code. However, OOA09 also allows entity names to be used within Action Language code instead. For this reason, key letters are not allowed to match another entity's name.

Key letters (often referred to as key letter singular in old Shlaer-Mellor literature) where introduced in OOA91 at a time when there was minimal CASE tool support. UML has no similar notion since it was defined with CASE tools in mind. That said, key letters still have a useful role to play with regards to event and operation labelling. Within OOA Tool, users can leave the creation and updating of key letters entirely in the hands of OOA Tool.

Key letters are also used to compose event and operation labels via the Label Prefix attribute on Operation Owner. While entity key letters are no longer strictly necessary in their own right, they are essential for use within event and operation labels since event and operation meanings are not by themselves unique. The format of event and operation labels will not be discussed here. However, they do rely on the fact that key letters are always unique.

OOA09 defines key lettering on the Entity object. It defines a Name attribute, an optional Custom Letters attribute, a mathematically dependent First Letters attribute and a mathematically dependent Key Letters attribute. The custom letters attribute allows users to specify their own key letters for an entity. However, the custom letters must be unique otherwise they will be ignored. The first letters attribute is derived from the name attribute and is composed from the first letter of each word in the name (see Naming). This is the recommended convention for key letters. However, first letters may not always be unique which is why custom letters may be needed for some entities.

OOA91 also defined the notion of subsystem prefix letters allowing an optional common key letters prefix to be defined for all objects within a subsystem. Prefix letters can't be defined for terminators since terminators are never assigned to a subsystem. OOA09 requires any prefix letters to be automatically added to assigned object key letters. The prefix letters must not be included in custom letters (otherwise it will be duplicated) and is not added to first letters. It is always added to key letters, i.e. it can't be selectively dropped from a single object's key letters. Prefix letters are not defined as a unique identifier on subsystem so two or more subsystems may use the same prefix letters. Prefix letters normally end with an underscore but that isn't a requirement.

All entity key letters must be unique within a domain. If custom letters (with any prefix letters added) is defined which doesn't match another entity's name or custom letters then it is used. Otherwise, first letters (with any prefix letters added) is used instead. If the first letters match another entity's name, custom letters or first letters then a suffix is added to make the final key letters unique. The suffix used is "_z", "_zz", "_zzz" etc. The convention is a little arbitrary but it does ensure key letters are always unique. Users should (but are not required to) define custom letters when first letters are not unique which will be obvious when the sleep suffix appears.

No comments: