liveBook · Manning

Condition

As explained in Building User-Friendly DSLs

The part of a business rule that specifies the circumstances under which the rule applies.

A condition specifies when a business rule applies. In the general form “When <condition>, then <consequence>,” it determines whether the consequence should be executed. section 14.0

Running a business rule evaluates its condition and executes the consequence only when the condition evaluates to true. Conditions can involve attributes of a record type, such as a rental period on Rental. section 14.0

A DSL for business rules must let domain experts:

  • Write logical expressions for condition parts, including expressions involving date ranges. section 14.1
  • Define business rules as part of a Record Type and provide their consequences separately. section 14.1
Figure 14.3 The general form of a business rule defined on a record type
figure

Diagram of the general business-rule form, including the condition and consequence parts. section 14.0

How Building User-Friendly DSLs covers it

How deep it goes
Defines condition evaluation and DSL requirements, but does not detail the implementation of logical expressions.
Examples
Uses rental periods, discounts, and date-range expressions to ground conditions in car-rental rules.
What it assumes
Assumes familiarity with earlier DSL techniques and introduces conditions through business-rule structure.
What you can do after
Build it from scratch by defining logical condition expressions within business rules in a domain-specific language.
How it connects
Connects conditions with business rules, consequences, record types, logical expressions, and date ranges.

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.