Skip to main content

Value Objects

Value Objects are a core concept in Domain-Driven Design (DDD). They encapsulate primitive values and enforce related invariants to maintain data integrity within your domain.

As defined in the DDD book by Eric Evans:

"An object that represents a descriptive aspect of the domain with no conceptual identity is called a Value Object. Value Objects are instantiated to represent elements of the design that we care about only for what they are, not who or which they are."

In the Codebricks Platform, Value Objects help structure and manage domain data effectively by grouping related properties and enforcing business rules.

Add Value Object

You can add a Value Object in two ways:

  1. During the modeling of the use case.
  2. Through the Value Object Management Panel.

Adding a Value Object During Use Case Modeling

To add a Value Object while modeling a use case:

  1. Open the Use Case details by clicking on an API Use Case on the map.
  2. Navigate to the details of a domain component such as Command or Aggregate Method.
  3. Edit or add a property you wish to assign a Value Object to.
  4. Click the + icon next to the Value Object dropdown.

Codebricks Planner with Add Property from a command open, highlighting the option to add a Value Object.

In the dialog that appears, specify the name of the Value Object. The type should be prefilled based on the property type.

Codebricks Planner with the Value Object creation dialog open.

After submitting, your Value Object will be automatically selected.

note

Please ensure all input fields in the Codebricks Planner use lowercase letters and spaces only.
Special characters are not allowed to ensure a smooth generation experience.

Select Value Object

To use a Value Object in a schema, follow these steps:

  1. Open the Use Case details by clicking on a Command Use Case on the map.
  2. Navigate to the details of the Command or Aggregate Method.
  3. Add or edit a property (See Use Case Schema Editing).
  4. Select the desired Value Object from the dropdown menu.

Codebricks Planner with Add Property from a command open, highlighting the option to select a Value Object.

Manage Value Objects

To create, edit, or delete Value Objects, use the Value Object Management Panel:

  1. Open the Use Case details by clicking on any Use Case on the map.
  2. Open the management panel by clicking on the Candy Box icon (Candybox icon).
  3. Navigate to the Value Objects tab.

Codebricks Planner with Value Object Management open, showing different Value Objects like title, description, etc.

Here, you can add, edit, or delete Value Objects.

warning

You can only delete Value Objects that are not currently in use within any Use Case or associated with a Value Object.