list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

Requirements

Requirements allow for the same comment to appear in different sections of the code without typing out the comment multiple times.

They consist of two components: the requirement definition, which contains the comment statement to be added, and the requirement implementation, which specifies where the requirement statement should be added.

Multiple requirements can be called through an implementsReq statement.


A requirement can be tagged with multiple entities like classes, attributes, associations, state machines, traits, methods, interface etc.


Requirement-definition syntax

A requirement is introduced with the req keyword, followed by an identifier and an optional requirement-language tag. The body is enclosed in curly braces:

req <ReqIdentifier> [<reqLanguage>] { ... }

The supported requirement languages are:

  • plain (default, tag may be omitted) — free text.
  • userStory — free text optionally structured with who, when, what, and why sub-blocks.
  • useCase (also written usecase) — free text, or the steps of an interaction between an actor and the system. See the section below.
  • quality — introduces named quality classes (e.g. High, Medium, Low) for a non-functional property. See Requirement Quality Classes.

useCase requirements

A useCase requirement describes an interaction between an actor and the system. Its body may be free text, or may be structured with any combination of the sub-blocks below, written one per line and in any order:

  • who, when, what and why — the same sub-blocks used by userStory requirements.
  • userStep <id> { ... } and systemResponse <id> { ... } — the steps of the scenario. The identifier may be a number or alphanumeric, and the steps are kept in the order they are written.
  • isA <ReqIdentifier> [, <ReqIdentifier>]* ; — the use case is a special case of the named use cases, as with UML generalization.
  • include <ReqIdentifier> [, <ReqIdentifier>]* ; — the use case incorporates the steps of the named use cases, as with the UML include relationship.

A step may carry a condition in square brackets, written like a state machine guard. The step applies only when the condition holds, so several steps can share one identifier to describe alternative outcomes of the same point in the scenario:

req UC5 useCase {
  isA UC3;
  include UC4;
  userStep 1 { select a payment method }
  systemResponse 1 [card accepted] { confirm the order }
  systemResponse 1 [card declined] { ask for another card }
}

See Requirements Examples for complete useCase models in plain, structured and related forms.

implementsReq statement

An implementsReq statement attaches one or more requirements to the surrounding entity. It can appear at the top level (binding to a following mixset or class), inside a class, trait, state machine, attribute, association, or method:

implementsReq <ReqIdentifier> [(<QualityClassName>)] [, <ReqIdentifier> [(<QualityClassName>)]]* ;

The optional parenthesised argument selects a specific quality class of the referenced requirement, which is required when using implementsReq to differentiate alternative designs on a non-functional property:

implementsReq Speed(High), Security(Perfect);
mixset DesignA { ... }

See also:


Example

req R01 {
  This is a comment we would like to add
  multiple times in different locations.

  The identifier used for this requirement is
  R01.
}

req R02 {
  This is a second requirement statement.
}

implementsReq R01;
class Example {
  implementsReq R02;
  var1;
  var2; implementsReq R01, R02;
}
      

Load the above code into UmpleOnline

 

Requirement tagging with multiple entities

req R1 {
  First requirement with the identifier R1.
}


req R2 {
  Second requirement with the identifier R2.
}


req R3 {
  Third requirement with the identifier R3.
}


req R4 {
  Fourth requirement with the identifier R4.
}


req R5 {
  Fifth requirement with the identifier R5.
}


req R6 {
  Sixth requirement with the identifier R6.
}


// Requirements tagged with class
implementsReq R3;
class A {
  
  // Requirements tagged with attribute
  implementsReq R2;
  att1;
}


// A second class
class B {
  
  // Requirement tagged with association
  implementsReq R2;
  * -> * A;
  
  // Requirement tagged with state machine
  implementsReq R3;
  sm {
    s1 {
      e -> s2;
    }
    s2 {
    }
  } 
  
  // Requirement tagged with method
  implementsReq R5;
  String m1(String s) {
    return(s);
  }
}


// Requirement tagged with trait 
implementsReq R4;
trait C {
   g;
}


// Requirement tagged with interface
implementsReq R6;
interface Itest {
  String m2(String s);
}



      

Load the above code into UmpleOnline