Logo BCDDLogo CSC
BCDDBehavioural Contract-Driven Design
version 1.0-beta
ITEN

Chapter 15 — The versions of boundaries

A new lamp keeps the light on longer for those going up to the top floors, and to do so it requires an indication of the floor from which the command comes. The command changes: the CSC Comando moves to version 0.2. The old button, however, provides only version 0.1. This chapter describes how to indicate a precise version of a CSC, in which cases two lines that cite the same CSC match, and how a part can provide two versions of the same boundary.

The indicated version

After the name of the CSC, in an OFFERS or USES line, a version can be indicated: USES Comando VERSION 0.2. The indicated version identifies the version of the CSC to which the line refers. A line without a version does not fix any: bcdd accepts the file of the CSC at any version, and a USES line without a version matches any OFFERS line of the same CSC. An OFFERS line without a version, on the other hand, does not satisfy a USES line that indicates a version (see the table below).

Version 0.2 of Comando adds the parameter piano to the event accendi:

-- The command that the button sends to the lamp.
-- VERSION 0.2: the command indicates the floor of the pressed button. Pending approval.

CSC Comando VERSION 0.2
  STATUS HYPOTHESIS
  PURPOSE "The button commands the lamp to switch on and indicates from which floor"

  EVENT OUT  accendi(piano: Integer [0 .. 5])

  GUARANTEE c1: VERBAL "At least 0.2 s pass between two accendi"
                VERIFY BY INSPECTION "the recorded commands"
  GUARANTEE c2: VERBAL "The parameter piano is the floor of the pressed button"
                VERIFY BY JUDGEMENT "a person who presses the button on each floor and reads the recorded commands"
END

A folder can contain only one file Comando.csc; version 0.2 is therefore in another folder, versioni, while 0.1 remains in the folder of the other files.

The new lamp indicates version 0.2:

-- The new lamp, which keeps the light on longer for those going up to the top floors.

ENTITY LampadaNuova VERSION 0.1
  STATUS HYPOTHESIS
  PURPOSE "The lamp switches on at the command and stays on longer if the command comes from the top floors"

  USES   Comando VERSION 0.2
  USES   Alimentazione
  OFFERS Luce

  GUARANTEE ln1: VERBAL "After an accendi the light switches on within 0.5 s"
                 VERIFY BY JUDGEMENT "a person who observes the lamp while the command is sent"
  GUARANTEE ln2: VERBAL "The light switches off 90 s after the last accendi, or 120 s after if the last accendi comes from the fourth or fifth floor, with a tolerance of 5 s"
                 VERIFY BY JUDGEMENT "a person with a stopwatch"
END

The match between two lines

A USES line of a part is satisfied if there is an OFFERS line of another part, or a USES line of the entity, with the same name and a version that matches:

The USES line of the part The other line Correspondence
USES Comando OFFERS Comando, with or without version yes
USES Comando VERSION 0.2 OFFERS Comando VERSION 0.2 yes
USES Comando VERSION 0.2 OFFERS Comando VERSION 0.1 no
USES Comando VERSION 0.2 OFFERS Comando, without version no

The last row of the table shows that an OFFERS line without a version does not satisfy a USES line that indicates a version. Versions are compared as character strings: 0.1 and 0.10 are different versions. bcdd does not assess whether two different versions are compatible in content: a version that only adds a parameter remains a different version.

The new lamp with the old button

The button of chapter 13 declares OFFERS Comando, without a version: when it was written only 0.1 existed. In an entity with the old button and the new lamp the report shows:

1. ERRORS: 2
  line 12: [E17] the part pulsante provides connector Comando: no other part of LuceScale uses it, nor does LuceScale provide it from outside
  line 13: [E14] the part lampada uses connector Comando VERSION 0.2: no other part of LuceScale provides it, nor does LuceScale use it from outside
…
8. USES WITHIN ENTITIES: 2
  line 13: lampada uses Comando VERSION 0.2: nobody provides it
  line 13: lampada uses Alimentazione: LuceScale uses it from outside (line 9)

The lamp indicates version 0.2 and no part provides it (E14); the command provided by the button does not match the USES line of the lamp, so no part uses it (E17). The same report is obtained if the button writes OFFERS Comando VERSION 0.1.

Two versions of the same boundary

In the block of flats the ground-floor lamp remains the old one and the new lamp is installed on the top floor. The button must then satisfy both lamps and provides the two versions of the command:

-- The staircase button, one of the parts of the light.
-- VERSION 0.2: provides the command in versions 0.1 and 0.2. Pending approval.

ENTITY Pulsante VERSION 0.2
  STATUS HYPOTHESIS
  PURPOSE "The button receives the press and commands the lamp"

  OFFERS Pressione
  OFFERS Comando VERSION 0.1
  OFFERS Comando VERSION 0.2

  GUARANTEE pu1: VERBAL "Each press is followed by an accendi within 0.1 s"
                 VERIFY BY INSPECTION "the recorded presses and commands"
END

An entity that provides two versions of the same CSC keeps the guarantees of each of them in full: the consumer of 0.1 can count on the guarantees of 0.1, the consumer of 0.2 on those of 0.2. The way in which the two versions coexist in the button is not written: it is a choice of whoever implements it.

To check the button, bcdd must find both versions of Comando. Without the option --dir it finds only the file in the folder of the checked file, which contains version 0.1, and reports it with expected VERSION 0.2, that is, with the version indicated in the line:

$ bcdd check --strict Pulsante.csc
bcdd check --strict Pulsante.csc
…
    line 9: OFFERS Comando in Comando.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 10: OFFERS Comando in Comando.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors, expected VERSION 0.2

The option --dir indicates another folder in which to search (chapter 13):

$ bcdd check --strict --dir versioni Pulsante.csc
bcdd check --strict --dir versioni Pulsante.csc
lines: 14 (recognised 9, comments 2, blank 3, unrecognised 0)
blocks: 1
  line 4: ENTITY Pulsante VERSION 0.2, STATUS HYPOTHESIS
    line 8: OFFERS Pressione in Pressione.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 9: OFFERS Comando in Comando.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 10: OFFERS Comando in versioni/Comando.csc at line 4: VERSION 0.2, STATUS HYPOTHESIS, no errors

1. ERRORS: 0

2. DEGREE OF THE CONTRACTUAL LINES
  verbal: 1
  formal: 0
  declared extension: 0
  unrecognised: 0
  line 12: GUARANTEE pu1 verbal

3. UNDECIDED: 0

4. PENDING APPROVAL, NOT CONTRACT: 1
  line 12: GUARANTEE pu1

5. UNRECOGNISED LINES: 0

6. UNDECLARED TYPES: 0

7. CSCs NAMED BUT NOT CHECKED: 0

8. USES WITHIN ENTITIES: 0

outcome: no errors

The entity with the two lamps:

-- The staircase light, with the old lamp on the ground floor and the new one on the top floor.

ENTITY LuceScale VERSION 0.1
  STATUS HYPOTHESIS
  PURPOSE "The person on the stairs presses the button and has light to go up or down"

  OFFERS Pressione
  OFFERS Luce
  USES   Alimentazione

  COMPOSED OF
    pulsante      : Pulsante
    lampada       : Lampada
    lampada_alta  : LampadaNuova

  GUARANTEE ls1: VERBAL "When someone presses the button, the light switches on"
                 VERIFY BY JUDGEMENT "a person who presses the button and watches"
END
$ bcdd check --strict LuceScale.csc
bcdd check --strict LuceScale.csc
lines: 18 (recognised 13, comments 1, blank 4, unrecognised 0)
blocks: 1
  line 3: ENTITY LuceScale VERSION 0.1, STATUS HYPOTHESIS
    line 7: OFFERS Pressione in Pressione.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 8: OFFERS Luce in Luce.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 9: USES Alimentazione in Alimentazione.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 12: pulsante : Pulsante in Pulsante.csc at line 4: VERSION 0.2, STATUS HYPOTHESIS, no errors
    line 13: lampada : Lampada in Lampada.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 14: lampada_alta : LampadaNuova in LampadaNuova.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors

1. ERRORS: 0

2. DEGREE OF THE CONTRACTUAL LINES
  verbal: 1
  formal: 0
  declared extension: 0
  unrecognised: 0
  line 16: GUARANTEE ls1 verbal

3. UNDECIDED: 0

4. PENDING APPROVAL, NOT CONTRACT: 1
  line 16: GUARANTEE ls1

5. UNRECOGNISED LINES: 0

6. UNDECLARED TYPES: 0

7. CSCs NAMED BUT NOT CHECKED: 0

8. USES WITHIN ENTITIES: 4
  line 13: lampada uses Comando: it is provided by pulsante (line 12)
  line 13: lampada uses Alimentazione: LuceScale uses it from outside (line 9)
  line 14: lampada_alta uses Comando VERSION 0.2: it is provided by pulsante (line 12)
  line 14: lampada_alta uses Alimentazione: LuceScale uses it from outside (line 9)

outcome: no errors

The old lamp uses Comando without a version and the new lamp indicates 0.2: the button satisfies both lamps. In the line of section 8 for the old lamp the button appears only once, even though it provides two versions that match the USES line of the lamp.

Summary

Special cases

Indicated version not found. If the new lamp is checked without --dir, version 0.1 is found:

    line 7: USES Comando in Comando.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors, expected VERSION 0.2

It is not an error: bcdd reports that the file found does not contain the indicated version.

Same CSC with and without a version. Among lines of the same type, a line without a version applies to all versions: written together with a line with a version of the same name, it is a duplicate of it (E01). The same holds for two lines with the same version. If line 3 is OFFERS Comando and line 4 OFFERS Comando VERSION 0.2, and lines 5 and 6 are both OFFERS Pressione VERSION 0.1, the report shows:

1. ERRORS: 2
  line 4: [E01] name already used at line 3: Comando
  line 6: [E01] name already used at line 5: Pressione