9 Preventing things from blowing up

 

This chapter covers

  • Determining the various ways the build system and Runtime can fail
  • Adding constraints to the DSL so that domain experts are warned about “faulty” DSL content that can cause failures
  • Strengthening the generator so it can deal with some failures

In chapter 8, we implemented a code generator to generate code from an AST representing DSL content. (This DSL content would be written using the Domain IDE.) That generator, and the generated code, worked for the AST of the example DSL content, and it would probably also work for a lot of other DSL content. However, some ASTs could cause the generator to produce code that can’t be built, or code that crashes or runs incorrectly. The generator itself can even crash on a particular AST—for example, when the generator expects some property to have a setting, but it doesn’t.

Figure 9.1 divides the process of building a Runtime from DSL content into several stages and indicates how they might fail.

Figure 9.1 Building the Runtime from DSL content, divided into several separate stages with their failure modes
figure

Table 9.1 explains these stages and their associated failure and success modes in a little more detail.

9.1 Preventing failures by adding constraints

9.2 A template case: Dealing with an attribute without a name

9.2.1 Constraint strategies

9.2.2 Implementing the constraints checker

9.3 Dealing with all attribute-related faults

9.3.1 An attribute without a type

9.3.2 An attribute with an initial value “with holes”

9.3.3 Related attributes with unequal types

9.3.4 Sorting attributes according to dependency order

9.3.5 Detecting cycles of attributes

9.3.6 Attributes with too similar names

Summary