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:
- During the modeling of the use case.
- Through the Value Object Management Panel.
Adding a Value Object During Use Case Modeling
To add a Value Object while modeling a use case:
- Open the Use Case details by clicking on an API Use Case on the map.
- Navigate to the details of a domain component such as Command or Aggregate Method.
- Edit or add a property you wish to assign a Value Object to.
- Click the + icon next to the Value Object dropdown.
In the dialog that appears, specify the name of the Value Object. The type should be prefilled based on the property type.
After submitting, your Value Object will be automatically selected.
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:
- Open the Use Case details by clicking on a Command Use Case on the map.
- Navigate to the details of the Command or Aggregate Method.
- Add or edit a property (See Use Case Schema Editing).
- Select the desired Value Object from the dropdown menu.
Manage Value Objects
To create, edit, or delete Value Objects, use the Value Object Management Panel:
- Open the Use Case details by clicking on any Use Case on the map.
- Open the management panel by clicking on the Candy Box icon (
).
- Navigate to the Value Objects tab.
Here, you can add, edit, or delete Value Objects.
You can only delete Value Objects that are not currently in use within any Use Case or associated with a Value Object.