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

Chapter 13 — An entity made of parts

The staircase light consists of two devices, a button and a lamp, which may be implemented by different people. This chapter describes how to divide an entity into parts, how to write the boundary between the parts and how bcdd checks that the entity is closed.

The parts

A part is an entity contained in another entity. The parts are listed under the line COMPOSED OF, one per line, in the form name : Entity. The line COMPOSED OF and the lines that follow it form the parts list. The first name, the part name, states the role of the part in the entity that contains it (pulsante); the second is the name of the entity that describes the part (Pulsante). The line COMPOSED OF is written only once.

At each press the button commands the lamp to switch on. There is therefore a boundary between the two parts, described by the CSC Comando, written from the side of the provider, that is, the button:

-- The command that the button sends to the lamp.

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

The two parts are entities, each in its own file. The button provides the press to the person on the stairs and the command to the lamp:

-- The staircase button, one of the two parts of the light.

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

  OFFERS Pressione
  OFFERS Comando

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

The lamp uses the command and the power supply and provides the light:

-- The staircase lamp, one of the two parts of the light.

ENTITY Lampada VERSION 0.1
  STATUS HYPOTHESIS
  PURPOSE "The lamp switches on at the command and switches off by itself"

  USES   Comando
  USES   Alimentazione
  OFFERS Luce

  GUARANTEE la1: 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 la2: VERBAL "The light switches off 90 s after the last accendi, with a tolerance of 5 s"
                 VERIFY BY JUDGEMENT "a person with a stopwatch"
END

The entity LuceScale lists the two parts:

-- The staircase light, made of a button and a lamp.

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

  GUARANTEE ls1: VERBAL "When someone presses the button, the light switches on"
                 VERIFY BY JUDGEMENT "a person who presses the button and watches"
  GUARANTEE ls2: VERBAL "The light switches off 90 s after the last press, with a tolerance of 5 s"
                 VERIFY BY JUDGEMENT "a person who measures with a stopwatch the time between the last press and switch-off"
  GUARANTEE ls3: VERBAL "During cleaning a press of the button does not change the mode"
                 VERIFY BY JUDGEMENT "the caretaker, who presses the button during cleaning"
END

The entity guarantees remain those of chapter 12. Since they are not yet approved, the entity remains at version 0.1 and is modified directly (chapter 10).

LuceScale neither provides nor uses Comando: the boundary between the two parts is internal to the entity and is not observable from outside. The person on the stairs continues to observe only the press and the light. There is no need to state how the command reaches the lamp from the button: the two parts cite the same CSC and therefore refer to the same events. The concrete characteristics of the medium, a wire or a signal, are not written in the CSC (chapter 25).

Every used boundary is offered

In an entity made of parts the rule every used boundary is offered applies: every CSC used by a part is provided by another part or is used by the entity itself towards the outside (in the report: from outside). In the example, the lamp uses Comando, which the button provides, and uses Alimentazione, which the entity uses from outside. The OFFERS line of a part does not satisfy the USES line of the same part.

The rule has two complements:

An entity that respects the rule and its two complements is closed. bcdd reports a missing closure with three errors: E14 for a CSC used by a part and not provided by any part, E16 for a public boundary not entrusted to any part, E17 for a CSC provided by a part and not used by any part.

The assumptions of the CSC Alimentazione must be satisfied by its consumer: by the entity towards the mains and by the lamp inside the entity. bcdd does not check this, because the assumptions are written in words.

The report

$ bcdd check --strict LuceScale.csc
bcdd check --strict LuceScale.csc
lines: 21 (recognised 16, 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 3: VERSION 0.1, STATUS HYPOTHESIS, no errors
    line 13: lampada : Lampada in Lampada.csc at line 3: VERSION 0.1, STATUS HYPOTHESIS, no errors

1. ERRORS: 0

2. DEGREE OF THE CONTRACTUAL LINES
  verbal: 3
  formal: 0
  declared extension: 0
  unrecognised: 0
  line 15: GUARANTEE ls1 verbal
  line 17: GUARANTEE ls2 verbal
  line 19: GUARANTEE ls3 verbal

3. UNDECIDED: 0

4. PENDING APPROVAL, NOT CONTRACT: 3
  line 15: GUARANTEE ls1
  line 17: GUARANTEE ls2
  line 19: GUARANTEE ls3

5. UNRECOGNISED LINES: 0

6. UNDECLARED TYPES: 0

7. CSCs NAMED BUT NOT CHECKED: 0

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

outcome: no errors

Below the entity the citations of the parts also appear: line 12: pulsante : Pulsante in Pulsante.csc at line 3 states that the entity Pulsante was found in the file Pulsante.csc.

Section 8, USES WITHIN ENTITIES, reports, for each CSC used by a part, who provides it:

Where bcdd looks for the cited files

For each cited CSC and for each part bcdd looks for the block with that name in this order:

  1. in the checked file;
  2. in the file with the same name and the extension .csc, in the folder of the checked file (Comando.csc for the CSC Comando);
  3. in the file with the same name and the extension .csc, in the folders indicated with the option --dir, in the order in which they are written.

Of a part, bcdd reads only the OFFERS and USES lines, not its parts nor the cited CSCs. Each entity is therefore checked in its own file: bcdd check Pulsante.csc checks the button and the CSCs it cites.

Summary

Special cases

Part removed from the list. If the button is removed from the list, no part provides the CSC used by the lamp, and the public boundary Pressione is not entrusted to any part:

1. ERRORS: 2
  line 7: [E16] the public connector Pressione of LuceScale (provided) is not assigned to any part
  line 12: [E14] the part lampada uses connector Comando: no other part of LuceScale provides it, nor does LuceScale use it from outside
…
8. USES WITHIN ENTITIES: 2
  line 12: lampada uses Comando: nobody provides it
  line 12: lampada uses Alimentazione: LuceScale uses it from outside (line 9)

Boundary provided by a part and not by the entity. If the line OFFERS Luce is removed from the entity, the light provided by the lamp is neither used by any part nor provided by the entity:

1. ERRORS: 1
  line 12: [E17] the part lampada provides connector Luce: no other part of LuceScale uses it, nor does LuceScale provide it from outside

Part not found. If the file Pulsante.csc does not exist, the part is listed in section 7 with the name of the entity not found, and the closure check is suspended:

1. ERRORS: 0
…
7. CSCs NAMED BUT NOT CHECKED: 1
  line 12: Pulsante

8. USES WITHIN ENTITIES: 2
  line 13: lampada uses Comando: no part found provides it (parts not checked: 1)
  line 13: lampada uses Alimentazione: LuceScale uses it from outside (line 9)

outcome: no errors

bcdd does not report the errors E14, E16 and E17 until all the parts have been found: a part not checked might provide the missing CSC. The outcome no errors, in this case, must be read together with section 7.