Document vs. models, how to bridge the gap ?#
We, engineers, love to draw diagrams and represent things schematically.
Despite the lack of formal meaning, diagrams help thinking and communicating intent.
Sometimes it even leads to a real engineering concept being named after the color used to draw it.
The red-green trees of the C# compiler Roslyn are called that because those were the whiteboard marker colors used to draw the data structure in the design meeting, and the terminology went on to name rust-analyzer’s rowan library.
On the other hand we are often required (despite the lack of eagerness) to fill plain text documents for contractual, traceability, or safety reasons. These are typical requirements specifications, technical specifications, …
These documents are needed, and I bet that in 20 years we will still be using those. The reasons for that are simple:
Not every stakeholder understands diagrams or models, and should not be expected to
Not every system property, assumption or goal can be relevantly represented as a diagram
Systems are primarily designed from requirements living in one or several contracts
The system architecture and design should reflect the expectations of the contracts
These reasons led me to think that Model-Based Systems Engineering nowadays feels like drawing boxes and arrows rather than thinking about the systems.
Even worse, translating these models to other engineers adds overhead and creates friction that kills the benefits of the modeling effort. An electrical engineer needs significant refinement of a SysML model to be able to work from it, and modeling-tool vendors concede part of the problem: SysML lacks use in phases like detail design and implementation, and it is a communication mechanism between those trained in the notation, as Vitech’s president puts it, “but what about everyone else?” Software engineers have largely walked away from the UML too: in Petre’s interviews of 50 professional software engineers, 35 used no UML at all and none used it wholeheartedly. Chances are that they won’t be using boxes-and-arrows modeling any time soon for specification.
This is where req takes a hybrid approach. The existing plain-text artifact can be translated into a req specification out of the box with no modeling effort. The model is then built from this plain-text specification by extracting nouns, verbs and any relevant pieces of information. The way these pieces of information relate, notably via formal requirements, creates the diagrams.
In concrete terms, consider the sentence “The system shall have a temperature of 30C”. One extracts “System” and “temperature” into a glossary, then rephrases it as System::temperature shall be equal to 30C.
This is how req can achieve bridging between old-school documents and beloved diagrams. In contrast to pure modeling languages such as SysML, the approach requires less upfront investment. The tradeoff is that the authors would have to follow a strict ontology and write requirements from lower level building blocks.
A tiny example#
Consider a plain-text specification containing these two sentences:
The room shall be kept warm.
The heater shall heat the room whenever it is too cold.
Extracting the nouns gives a glossary: a Room with a temperature and a Heater with a power.
Rephrased against that glossary, the sentences become requirements:
package System
part Room
let temperature in real \ C \
part
part Heater
let power in real \ W \
part
requirement Keep_warm top
on Room
is
@@
The [[Room]] shall be kept warm.
@@
requirement
requirement Warm_enough bottom
on Room::temperature
refines Keep_warm
is
Room::temperature >= 20
requirement
requirement Heater_role top
on Heater
is
@@
The [[Heater]] shall heat the [[Room]] whenever it is too cold.
@@
requirement
requirement Heat_when_cold bottom
on Heater::power
refines Heater_role
is
Room::temperature < 20 implies Heater::power > 0
requirement
package
As the coupling is implicit it is hard to identify the arrow between Heater and Room.
It is there because Heat_when_cold reads the temperature of one to constrain the power of the other.
Collect such links over the whole specification and a diagram can be derived:
classDiagram
class Room {
temperature : real [C]
}
class Heater {
power : real [W]
}
Heater ..> Room : Heat_when_cold
Diagram derived from the specification above#
Qitab, the editor for req, already draws similar interaction diagrams.
The same reading gives other diagrams: the refines links, for instance, give the traceability tree between requirements.