👨‍💻
Software Engineering
Implementing Domain Driven Design
Implementing Domain Driven Design
  • Intro
  • 1. Getting Started with DDD
    • The Business Value of DDD
  • 4: Architecture
  • 5: Entities
    • Why We Use Entities
    • Unique Identity
  • 6: Value Objects
    • Value Object Characteristics
    • Integrate with Minimalism
    • Standard Types Expressed as Values
    • Resources
  • 10: Aggregates
  • 8: Domain Events
    • The When & Why of Domain Events
    • Modeling Events
    • Publishing Events from the Domain Model
  • 13: Factories
  • Resources
Powered by GitBook
On this page
  • Definition
  • Examples
  • Standardization
  • Implementation
  • Separate Bounded Context
  • Enum
  • Aggregate
  1. 6: Value Objects

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

Best to be biased towards an Enum for Standard Types

  • 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?

      • Use the Parallel Change Pattern

Aggregate

Think twice before you run with this.

  • 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.

PreviousIntegrate with MinimalismNextResources

Last updated 1 year ago