concept dsl in category system administration

appears as: DSL, DSLs, DSL
Functional and Reactive Domain Modeling

This is an excerpt from Manning's book Functional and Reactive Domain Modeling.

  • Denotation— Now that you have the dumb AST, you need to supply an interpreter to make it execute according to your requirements. The free monad has done the accumulation part (which the flatMap does), but didn’t execute the collapsing of the monadic context. This is how the flatMap handed over the AST itself. The interpreter traverses the AST and defines the semantics of the DSL. The interpreter has the context of application. If you want your AST to be executed and the result returned as a disjunction of error and values, you can implement the interpreter that way. If you want to execute the AST asynchronously, you can return a Future from your interpreter. The interpreter applies the context on top of the pure data that the free monad gives you.
  • The preceding steps introduce a layer of indirection between the definition of the DSL structure and the interpretation. In the earlier example in section 5.2.1, the DSL for composing sequences of operations from AccountRepository already had its execution sequence defined by the monadic context of scalaz.\/. The interpreter provided the implementation of the abstract methods. In this case, the free monad leaves the execution sequence undefined, and it’s up to the interpreter to fix that, traversing through the AST.

    Here are the various actions on the repository that you’ll support. Let’s keep it simple for the time being, because the idea is to get an understanding of how free monads help compose DSLs and decouple the algebra from the interpretation. The following listing defines the data types for the actions you support.

    Open Source SOA

    This is an excerpt from Manning's book Open Source SOA.

    Table 2.4. Open source selection criteria, general guidelines

    Criteria

    Comments

    Centralized rule repository and classification Central to the concept of EDM is a repository that enables rules to be classified, managed, and versioned. This should include the ability to add custom metadata and properties to each rule and ruleset. Security and access control are also important requirements.
    Auditing and logging In a time of increasing regulatory and compliance demands, the ability to audit the frequency and outcome of rule actions is essential. This can also provide analytical feedback to rule authors, allowing them to refine and improve their rules over time.
    Integrated development environment (IDE) A complete authoring environment for design, creating, testing, and publishing rules. Usually should include “wizards” or other forms of assistance for those new to the system.
    Domain-specific language (DSL) support We alluded to this briefly earlier: the ability to create a language based on business or domain nomenclature. An example of a rule expressed using a DSL is, “If Order is greater than $10,000, then sales manager approval is required.” That, in turn, would be translated into a form that the rules engine could understand.
    Robust API Refers to the ability to integrate with the rules engine. This means not only providing programmatic access to the rule engine, but also whether it includes support for reading/writing data from popular SQL databases, where most fact-related data resides. In addition, the API should support multiple languages and/or have strong web services support.
    Performance Although performance was listed in section 2.1, it is worth reiterating because of the importance performance plays within an EDM. It’s not uncommon to develop thousands of rules, and a highly efficient engine must be used since many rules must be fired in a real-time capacity.

    One of the major challenges facing all rules engine vendors is how to make the definition of rules more like natural language. Since the intention is for business users to craft rules, this is considered an important requirement. It has been met with varying degrees of success, since the vocabulary for rules is often very domain specific. The Drools approach to this conundrum is to use a templating mechanism that allows developers to create DSLs that can be language specific to the context or domain in which they’re used. Let’s create a simple DSL for our Hello World example, and you’ll see how straightforward the process is.

    11.8.1. Using DSLs for business user authoring

    The easiest approach we’ve found for creating a DSL is to start with an existing rule or rules, and then consider how the rule’s syntax can be made to resemble natural language. In listing 11.4, we defined a rule with a pattern that identified a Person whose age was less than 25 and who was a male. The when condition was specified as

    The real power behind using DSLs becomes most evident when using the Drools’ Eclipse rule editor (or editing within Guvnor, discussed in the next chapter). When editing, code expansions can be used to select a predefined template, and the author can then just replace the tokens with actual values. Figure 11.7 shows the editor in use; I pressed Ctrl+Spacebar to access the pop-up list of template options.

    Figure 11.7. An example of the Eclipse rule editor using DSL