liveBook · Manning

Consequence

As explained in Building User-Friendly DSLs

The part of a business rule that specifies how a value in the rule’s record type is set or changed.

A consequence is the part of a business rule that specifies what happens when its condition is true. It sets or changes a value in the record type where the rule is defined. section 14.0 section 14.4

A consequence participates in business-rule execution as follows:

  • The runtime evaluates the rule’s condition and executes the consequence when that condition produces true. section 14.0
  • A consequence that alters data or otherwise does more than consume computation is an effect; executing it applies that effect. section 14.4
  • Business rules can generate runtime code, with their effects gathered in a data structure rather than grouped by affected attribute. section 14.4

Rental discount

A rule defined on the Rental record type can compute and set a rental’s discount instead of leaving that value to the Runtime UI user. section 14.0

Figure 14.3 The general form of a business rule defined on a record type
figure

Shows the general business-rule form and the relationship between condition and consequence. section 14.0

How Building User-Friendly DSLs covers it

How deep it goes
Defines consequence semantics, effect terminology, and runtime execution without detailing a particular consequence implementation.
Examples
Uses a Rental rule that computes the discount attribute instead of accepting it from the Runtime UI.
What it assumes
Assumes record types and logical conditions, while establishing how those conditions trigger value changes.
What you can do after
Evaluate business-rule conditions and apply consequences that set or change record-type values.
How it connects
Connects condition, business rule, record type, effect, runtime, and code generation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building User-Friendly DSLs. The section links point to the parts of the book it draws on.