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

Chapter 4 — The two sides of a boundary

A CSC describes a boundary, which has two sides (chapter 1). The chapter states from which side it is written and how whoever is on the other side reads it. On the basis of this rule an element is added to the light that goes from the installation to the person on the stairs: a warning shortly before it switches off.

Provider and consumer

Of the two sides of a boundary, one keeps the guarantees and the other makes use of them:

A CSC is always written from the provider's side. The lines of the file must therefore be read from the point of view of the installation:

Line From the provider's side From the consumer's side
EVENT IN what arrives at it what it sends
EVENT OUT what it sends what arrives at it
STATE what it shows what it observes
GUARANTEE what it guarantees what can be relied on
ASSUME what it presupposes what it must satisfy

The consumer reads the same lines the other way round. The CSC is not rewritten from the consumer's side: there is only one description for each boundary, shared by both sides.

The output event

The warning is something that happens at an instant and goes from the installation to the person on the stairs. From the provider's side it is therefore an output event, written with EVENT OUT:

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

CSC UsoLuce VERSION 0.1
  PURPOSE "The person on the stairs presses a button and has light to go up or down"

  EVENT IN  premuto
  EVENT OUT avviso
  STATE     accesa : Boolean INITIAL false

  GUARANTEE g1: VERBAL "When someone presses the button, the light switches on"
                VERIFY BY JUDGEMENT "a person who presses the button and watches"
  GUARANTEE g2: VERBAL "The light switches off by itself after a while"
                VERIFY BY JUDGEMENT "a person with a watch"
  GUARANTEE g3: VERBAL "Shortly before switching off, the light gives a warning to the person on the stairs"
                VERIFY BY JUDGEMENT "a person on the stairs who waits for the light to switch off"
  ASSUME    a1: VERBAL "Whoever presses the button holds it down for at least a tenth of a second"
                VERIFY BY JUDGEMENT "a person who observes how the button is pressed"
END

The line EVENT OUT avviso declares only that the event exists. The moment at which the installation sends it is established by guarantee g3: without a guarantee, nothing obliges the installation to send it. What the warning concretely consists of, a short flash or an acoustic signal, is not written here (chapter 25).

The direction of an event indicates who has the obligation. An output event is a commitment of the provider, governed by its guarantees; an input event is something that the provider receives, and for which it can only formulate assumptions.

The report

$ bcdd check --strict UsoLuce.csc
bcdd check --strict UsoLuce.csc
lines: 18 (recognised 14, comments 1, blank 3, unrecognised 0)
blocks: 1
  line 3: CSC UsoLuce VERSION 0.1, without STATUS

1. ERRORS: 0

2. DEGREE OF THE CONTRACTUAL LINES
  verbal: 4
  formal: 0
  declared extension: 0
  unrecognised: 0
  line 10: GUARANTEE g1 verbal
  line 12: GUARANTEE g2 verbal
  line 14: GUARANTEE g3 verbal
  line 16: ASSUME a1 verbal

3. UNDECIDED: 0

4. PENDING APPROVAL, NOT CONTRACT: 4
  line 10: GUARANTEE g1
  line 12: GUARANTEE g2
  line 14: GUARANTEE g3
  line 16: ASSUME a1

5. UNRECOGNISED LINES: 0

6. UNDECLARED TYPES: 0

7. CSCs NAMED BUT NOT CHECKED: 0

outcome: no errors

Summary

Special cases

The same name for input and output. An event has a single name throughout the CSC. If the warning is also called premuto:

1. ERRORS: 1
  line 7: [E01] name already used at line 6: premuto

Event without direction. The line EVENT avviso, without IN or OUT, is not recognised:

5. UNRECOGNISED LINES: 1
  line 7: EVENT avviso
…
outcome: no errors; unrecognised lines: 1 (--strict)

The CSC written from the consumer's side. A second CSC with EVENT OUT premuto and EVENT IN avviso, written from the point of view of the person on the stairs, adds no information: it describes the same boundary with the directions reversed and requires two descriptions to be kept aligned. A single CSC is written, from the provider's side.