Standard Types Expressed as Values

Definition

  • Standard Types are descriptive objects that indicate the types of things.

  • The industry lacks a standard name for this concept.

    • Also referred to as a Lookup or Type Code.

Examples

  • Phone Number Type: Home, Mobile, Work, Other

  • Currency Type: USD, CAD, CNY, EUR, GBP, etc

  • Medication Administration Type: IV, Oral, Topical

Why not use a string? Strings allows the model to be put into an invalid state.

Standardization

Depending on the level of standardization, options for maintaining these types can include:

  1. Application Level

  2. Shared Corporate Database

  3. National or International Standards

Implementation

Separate Bounded Context

  • For the sake of maintenance, it is common for Standard Types to reside in a separate Context from the models that consume them.

  • The would be modeled as Entities with a persistent lifecycle.

  • Attributes would include Id, Name, Description, and more.

Enum

  • An Enum is very simple way to support a Standard Type

  • Provides a well-defined finite number of Values.

  • Lightweight

  • Side-Effect-Free behavior (not an Entity)

  • What about a description?

    • This is a User Interface Concern.

    • User Interface will often need to support localization. Localization is not an appropriate model concern.

  • What about the name?

    • Often the Name of the Standard Type is the best value to use.

    • What about when names change?

Aggregate

  • Implement one instances of an Aggregate per Type.

  • Think twice before you run with this.

    • Standard Types should generally NOT be maintained inside the Bounded Context that consumes them

    • Widely used Standard Types should normally be maintained in a separate Context with carefully planned updates to consumers.

  • Instead, expose standard type aggregates as immutable consumer contexts.

Last updated