Domain and Subdomain

As bounded contexts, domains are defined on the root level of a CML (*.cml) file. They provide a container to specify all subdomain which are then referenced on a bounded context with the implements keyword. See bounded context.

Syntax

The following example illustrates how you can specify a domain with subdomains in CML:

/* Syntax example: Domain and Subdomains */
Domain Insurance {
  Subdomain CustomerManagementDomain {
    type = CORE_DOMAIN
    domainVisionStatement = "Subdomain managing everything customer-related."

    Entity Customer {
      String firstname
      String familyname
    }

    /* Add more entities ... */
  }

  Subdomain ContractManagementDomain {}

  /* Add more subdomains ... */
}

Subdomain Type

With the type keyword you specify of which type your subdomain is. The following types exist:

  • CORE_DOMAIN
  • SUPPORTING_DOMAIN
  • GENERIC_SUBDOMAIN

Domain Vision Statement

With the domainVisionStatement keyword you can specify the vision statement for this subdomain, according to the DDD Domain Vision Statement pattern.

Entities

In order to provide further details about your subdomain and which domain objects are part of it, you can use entities within a subdomain. Note that the used Entity rule is integrated from the Sculptor DSL. For more details about the features and possibilities of this Entity rule, we refer to the Sculptor documentation. An example of a simple entity with attributes is illustrated above.