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

Chapter 17 — The size of an entity

The staircase light is divided into a button and a lamp. The lamp could be divided further, into a relay, a timer and a light bulb. This chapter provides the criterion for establishing when an entity has the appropriate size and when it should not be divided further.

The criterion

Whoever implements an entity, a person or a language model, works from its description. An entity has the appropriate size when whoever implements it is able to consider together:

The neighbouring parts of a part are the other parts of the same entity that cite one of its CSCs: the button and the lamp are neighbouring parts, because both cite Comando. Of a neighbouring part only what is observable from outside counts: the CSCs it cites and its entity guarantees, not its parts nor the way it is implemented.

If an entity is too large to be considered in full, it is divided into parts, each of which respects the same criterion. The language does not fix a numerical threshold: the criterion indicates an upper limit, not a lower one.

Why the light is divided into button and lamp

The button and the lamp are implemented by different people, with different skills, and the command that passes between them is observable. Each of the two parts is described with few boundaries and few guarantees, and the division reduces what each implementer must consider.

The lamp, on the other hand, is not divided further. The relay, the timer and the light bulb are choices of whoever implements the lamp (chapter 1): nothing passes between them that needs to be observable from outside the lamp. Describing them as parts would fix choices that belong to the implementer, without reducing what the implementer must consider.

The sign of excessive division

An entity consisting of a single part, which provides and uses the same boundaries as the part, repeats the part without adding anything: it is the sign of excessive division.

-- The lamp divided further: an entity with a single part.

ENTITY Apparecchio VERSION 0.1
  STATUS HYPOTHESIS
  PURPOSE "The device of the staircase lamp"

  USES   Comando
  USES   Alimentazione
  OFFERS Luce

  COMPOSED OF
    lampada : Lampada
END
$ bcdd check --strict Apparecchio.csc
…
8. USES WITHIN ENTITIES: 2
  line 12: lampada uses Comando: Apparecchio uses it from outside (line 7)
  line 12: lampada uses Alimentazione: Apparecchio uses it from outside (line 8)

outcome: no errors

The report shows no errors: excessive division is not a writing error, and recognising it is the responsibility of whoever writes. The entity Apparecchio is removed, and Lampada is used directly in its place.

Summary

Special cases

Entity too large. bcdd does not measure the size of an entity: an entity with many boundaries and many guarantees is as correctly written as a small one. Applying the criterion is left to the judgement of whoever writes.

Parts without observable boundaries. If nothing observable passes between two candidate parts, there is no CSC to write between them: the two parts are, in fact, a single entity.