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

Chapter 25 — The concrete form of boundaries

The CSCs of the previous chapters indicate what happens at a boundary with names chosen by the writer: premuto, accendi, modo = accesa, avviso. This chapter introduces concrete forms, that is the way in which each of these elements appears at the boundary, and the criterion by which what to write is established, “who sees it?”. Finally it introduces the BINDING block, which contains the concrete forms.

Concrete forms

A concrete form is what someone at the boundary observes or uses of an element of a CSC: a terminal, a text on the screen, a colour, a file format, a command-line option, a message on a network. The CSC establishes that an element exists and what the provider guarantees; the concrete forms establish how that element appears at the boundary. In chapter 4, for example, the line EVENT OUT avviso declares that the warning exists, whereas its appearance, a brief flash or an acoustic signal, is a concrete form. In the same way, in a program with a window the CSC can declare a state allarme : Boolean, and the concrete forms establish that the alarm appears as the word “ALARM” in red.

The concrete forms of a boundary are written in a BINDING … END block, distinct from the CSC block of the boundary. The concrete forms concern:

Concrete forms add no guarantees: they indicate how the elements the guarantees refer to appear at the boundary.

The criterion “who sees it?”

To decide where an element is written, the specification asks a single question: who sees it, and how.

Situation Where it is written
nobody at the boundary sees it it is not written: it is implementation
someone sees it, and its form can change without changing the meaning of the guarantees in the concrete forms
someone sees it, and changing it changes the meaning of the guarantees in the CSC
the number that makes a guarantee checkable is derived only from an existing implementation in the CSC, as an undecided number (UNDECIDED), with a question to the approver
an existing implementation produces a visible effect, but nothing indicates that it is intended neither in the CSC nor in the concrete forms: the question is put to the approver

A concrete form is binding when someone who is not part of the same implementation observes or uses it: a person, another program, a third-party system.

The concrete forms of the light

The table applies the criterion to the elements of the CSC UsoLuce (chapters 21-23) and of the CSC Comando, the boundary between the button and the lamp (chapter 13).

CSC Element Who sees it Concrete form
UsoLuce premuto the person on the stairs press of the key of the wall button
UsoLuce modo = spenta the person on the stairs lamp off
UsoLuce modo = accesa, modo = in_pulizia the person on the stairs lamp on
UsoLuce avviso the person on the stairs the lamp switches off for 0.3 s and switches on again
Comando accendi whoever implements the lamp contact closed between terminal 3 and the common terminal for at least 50 ms

accesa and in_pulizia have the same concrete form: the person on the stairs does not tell them apart by sight, and observes the difference only in the behaviour, because during cleaning a press does not change the mode (chapter 6).

The warning. With a flash or with an acoustic signal the guarantees keep their meaning: for this reason the appearance of the warning is a concrete form. The advance with which the warning precedes the switch-off, by contrast, changes what the person on the stairs can expect, and is written in the CSC: it is the named constant ANTICIPO_AVVISO of chapter 8.

Terminal 3. Comando is a boundary internal to the entity LuceScale (chapter 13). If the button and the lamp are implemented by two different manufacturers, whoever implements the lamp must know which contact represents an accendi: terminal 3 and the minimum duration of 50 ms are binding concrete forms. If instead the button and the lamp are implemented together, nobody outside that implementation uses the terminal, which remains an internal choice. The minimum duration establishes which contact counts as accendi; modifying it changes neither guarantee c1 of Comando nor the assumption a1 of UsoLuce.

The relay. The relay that closes the lamp circuit is not visible to the person on the stairs (chapter 1): it is implementation and is not written. The sentence “accesa means relay closed” would exclude a lamp that keeps the same guarantees without a relay.

A number taken from an implementation. If the advance of the warning is derived only from an already installed module, which emits the warning 5 seconds before the switch-off, the number has not been decided by anyone: in the CSC ANTICIPO_AVVISO := UNDECIDED remains, and the approver is asked which value to establish.

A behaviour that nobody requested. When switching on, the relay of the installed module produces an audible click. The person on the stairs hears it, but nobody requested it: it is not written in the CSC, and the approver is asked whether it should be kept. If so, the click becomes an element of the CSC with its concrete form; otherwise it remains a characteristic of the implementation, which another lamp may not have.

The BINDING block

The concrete forms of the light are written in a file of their own, FormeLuce.csc:

-- The concrete forms of the staircase light, as seen by the person on the stairs.

BINDING UsoLuce VERSION 0.3
  STATUS HYPOTHESIS
  BIND premuto: VERBAL "press of the key of the wall button"
  BIND modo:    VERBAL "spenta: lamp off; accesa and in_pulizia: lamp on"
  BIND avviso:  VERBAL "the lamp switches off for 0.3 s and switches on again"
END

The header BINDING UsoLuce VERSION 0.3 names the bound CSC, with its version. Each line BIND element: VERBAL "…" describes in words the concrete form of an element of the bound CSC: a state, an event, a request or a named constant, or the parameter of an event or of a request, written event.parameter. Several BIND lines for the same element describe different aspects of the same form. A BIND line is not a guarantee: it has neither VERIFY nor DETAILS. The block has no PURPOSE; its header holds STATUS and the IMPORT PROFILE lines.

$ bcdd check FormeLuce.csc
bcdd check FormeLuce.csc
lines: 8 (recognised 6, comments 1, blank 1, unrecognised 0)
blocks: 1
  line 3: BINDING UsoLuce VERSION 0.3, STATUS HYPOTHESIS
    line 3: CSC UsoLuce in UsoLuce.csc at line 4: VERSION 0.3, STATUS HYPOTHESIS, no errors

1. ERRORS: 0

2. DEGREE OF THE CONTRACTUAL LINES
  verbal: 0
  formal: 0
  declared extension: 0
  unrecognised: 0

3. UNDECIDED: 0

4. PENDING APPROVAL, NOT CONTRACT: 3
  line 5: BIND premuto
  line 6: BIND modo
  line 7: BIND avviso

5. UNRECOGNISED LINES: 0

6. UNDECLARED TYPES: 0

7. CSCs NAMED BUT NOT CHECKED: 0

12. MISSING CONCRETE FORMS: 1
  line 3: BINDING UsoLuce VERSION 0.3: CAPABILITY Pulizie

outcome: no errors

bcdd looks for the bound CSC as it looks for a CSC cited by an entity (chapter 15): in the same file, in the file UsoLuce.csc of the same folder, then in the folders indicated with --dir. The CSC found appears under the line of the block. For a BIND line that names an element that the bound CSC does not declare, bcdd reports error E31.

Section 12, MISSING CONCRETE FORMS, lists the states, events and requests of the bound CSC that no BIND line of the block names: here the request Pulizie, whose concrete form, for example the caretaker's panel, is not yet written. An entry of section 12 is not an error. The section appears only when the file contains at least one BINDING block.

A BINDING has a status, like a CSC: its BIND lines are pending approval and appear in section 4.

Several concrete forms for the same boundary

A boundary can have several blocks of concrete forms. The CSC Comando has two: one for the wired button and one for the wireless button of chapter 14. The CSC remains a single one, and each block has a distinguishing name, written after AS, which the verification plan uses to cite it (chapter 26):

-- The command that the button sends to the lamp, with the concrete forms of the wired button and of the wireless one.

CSC Comando VERSION 0.1
  STATUS HYPOTHESIS
  PURPOSE "The button commands the lamp to switch on"

  EVENT OUT  accendi

  GUARANTEE c1: VERBAL "At least 0.2 s pass between two accendi"
                VERIFY BY INSPECTION "the recorded commands"
END

BINDING Comando VERSION 0.1 AS filo
  STATUS HYPOTHESIS
  BIND accendi: VERBAL "closed contact between terminal 3 and the common terminal for at least 50 ms"
END

BINDING Comando VERSION 0.1 AS radio
  STATUS HYPOTHESIS
  BIND accendi: VERBAL "a radio message ACCENDI with the code of the button, repeated three times in 30 ms"
END
$ bcdd check ComandoForme.csc
bcdd check ComandoForme.csc
lines: 21 (recognised 15, comments 1, blank 5, unrecognised 0)
blocks: 3
  line 3: CSC Comando VERSION 0.1, STATUS HYPOTHESIS
  line 13: BINDING Comando VERSION 0.1 AS filo, STATUS HYPOTHESIS
    line 13: CSC Comando in this file at line 3
  line 18: BINDING Comando VERSION 0.1 AS radio, STATUS HYPOTHESIS
    line 18: CSC Comando in this file at line 3

1. ERRORS: 0
…
4. PENDING APPROVAL, NOT CONTRACT: 3
  line 9: GUARANTEE c1
  line 15: BIND accendi
  line 20: BIND accendi
…
12. MISSING CONCRETE FORMS: 0
  line 13: BINDING Comando VERSION 0.1 AS filo: none
  line 18: BINDING Comando VERSION 0.1 AS radio: none

outcome: no errors

In the checked file, for two BINDING blocks of the same CSC and the same version without a distinguishing name, or with the same distinguishing name, bcdd reports error E40.

The approval of concrete forms

bcdd ratify approves a BINDING like a CSC: the header or, with --all, the header and the BIND lines that have their own STATUS HYPOTHESIS (BIND element STATUS HYPOTHESIS: VERBAL "…"). BIND lines have no short name, so they are not approved one by one. The block to approve is chosen with --csc NAME, where NAME is the distinguishing name of the BINDING. Without --csc, in a file that contains a CSC, ratify chooses the CSC:

$ bcdd ratify ComandoForme.csc --all D-21
approved with D-21 in CSC Comando: 1 line
  line 4: CSC Comando
contract: 1
$ bcdd ratify ComandoForme.csc --csc filo --all D-21
approved with D-21 in BINDING Comando VERSION 0.1 AS filo: 1 line
  line 14: BINDING Comando VERSION 0.1 AS filo
contract: 1
$ bcdd ratify ComandoForme.csc --csc radio accendi D-21
bcdd ratify: in a BINDING the header or --all is approved, not a line

A BINDING without a distinguishing name, in the same file as its CSC, is not chosen with the name of the CSC: that name designates the CSC. To approve it with ratify it is given a name with AS, or it is written in a file of its own, where it is the only block to approve and ratify chooses it without --csc.

The approval concerns the concrete forms of the block, not the guarantees of the bound CSC, which are approved separately.

Summary

Special cases

The same relay on another boundary. If the lamp is a module sold with the relay contacts brought out to the output terminals, to which the installer connects the bulbs, the installer observes and uses those contacts. That boundary, between the module and whoever installs it, is described by another CSC, and on it the relay contact is a concrete form. The criterion applies boundary by boundary: the same object can be implementation for the person on the stairs and concrete form for the installer.

An element that the CSC does not declare. A line BIND spia: VERBAL "the green indicator light of the button" names an element that UsoLuce does not declare:

1. ERRORS: 1
  line 7: [E31] spia is not an element of CSC UsoLuce VERSION 0.3

If the bound CSC is not found, or is found only in another version, the check of the elements is suspended: the CSC appears in section 7.

A VERIFY line after a BIND line. A concrete form is not verified like a guarantee. A VERIFY line written under a BIND line is a line on its own, unrecognised:

5. UNRECOGNISED LINES: 1
  line 8: VERIFY BY INSPECTION "the recording of the lamp"
…
outcome: no errors; unrecognised lines: 1 (--strict)

A concrete form written as a guarantee. The concrete form of accendi can be written in the CSC as a guarantee in words, and bcdd recognises it:

  GUARANTEE c2: VERBAL "Every accendi is a closed contact between terminal 3 and the common terminal for at least 50 ms"
                VERIFY BY INSPECTION "the contact recorded on terminal 3"
2. DEGREE OF THE CONTRACTUAL LINES
  verbal: 2
  formal: 0
  declared extension: 0
  unrecognised: 0
  line 9: GUARANTEE c1 verbal
  line 11: GUARANTEE c2 verbal

The line is not to be written in the CSC. A button that sent the accendi by radio would keep guarantee c1 but not c2: changing the form would require a new version of the CSC and a new approval, even though the behaviour remains the same.

The block inside the CSC. A BINDING stands outside every other block. Written before the END line of the CSC, it interrupts the CSC, which remains without END; the END line of the CSC no longer has an open block to close:

  BINDING Comando VERSION 0.1
  END
END
1. ERRORS: 2
  line 3: [E07] unclosed block: END of CSC Comando is missing
  line 14: [E08] END without an open block

Two blocks without a distinguishing name. Without AS filo and AS radio the two blocks of Comando cannot be told apart:

1. ERRORS: 1
  line 18: [E40] second BINDING without a name for CSC Comando VERSION 0.1: the first is at line 13. With two or more BINDINGs, each has a name: AS name

Concrete forms and implementation. Concrete forms describe only what is observed at a boundary. The routing of the wires inside the box, the type of relay or the program of an electronic timer are implementation and do not appear in any block, not even when the electrician needs to know them to build the installation.