Questions tagged [value-objects]

A value object is a fundamental concept of domain modeling in Domain-Driven Design.

A value object is a fundamental concept of domain modeling in Domain-Driven Design.

As defined by Eric Evans in his book, Domain-Driven Design: Tackling Complexity in the Heart of Software:

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.

324 questions
1
vote
1 answer

How to account for empty values in nested VO objects

I have inherited a vo/dao setup (there's just one model class that has all the DAO functions for every class, though), but it's getting odd with recursion. Every user has posts, each post can have a video, but videos also have users, and sometimes a…
Damon
  • 10,493
  • 16
  • 86
  • 144
1
vote
3 answers

Mutable Value Objects / Sharing State (and beer brewing!)

I'm a rusty programmer attempting to become learned in the field again. I've discovered, fitfully, that my self-taught and formal education both induced some bad habits. As such, I'm trying to get my mind around good design patterns, and -- by…
Tony Wooster
1
vote
0 answers

Interface as a field in Value Object in DDD

Does it make sense to create a field in ValueObject as an interface? I have a field in my aggregate that represents its status. The state has a natural event-driven flow, but there are times where the state can be set manually. Currently I have an…
Mr. Lennon
  • 11
  • 3
1
vote
2 answers

Domain Driven Design - Can you use a simplified existing Aggregate in a different Aggregate Root

I have an aggregate called Survey - you can create a Survey, send a Survey and respond to a Survey. I also have an aggregate called Person. They can receive a Survey and respond to a Survey. This aggregate includes demographic information that…
1
vote
2 answers

DDD: Domain Objects Structure

I'm new to DDD and I want to clearly understand each domain object structure and role: Aggregate Root: 1.1. The only contact point the client can interact with the domain objects, the client should not be able to modify or create new Entities or…
1
vote
0 answers

How can I use SumAsync to calculate sum of a customized value object in Asp.Net core

I have a Model with a property of a value object type as following: public class Course : AggregateRoot, ISpModel { ... public UnsignedNumber MaximumCapacity { get; private set; } ... } with UnsignedNumber being a value object…
1
vote
0 answers

How to create a generic JsonConverter for Value Object serialization?

I'm storing domain objects as JSON in the database. To store DDD value objects I need to create a JsonConverter. I'm trying to create a generic value object converter in System.Text.Json. I have seen the following related questions in SO and…
1
vote
1 answer

I have a problem when I use Value object with JPA

I must use ValueObject in the project and JPA at the same time, but when changing the attribute to valueobject it gives me an error, I don't know yet how to solve the problem this error: ('Id' attribute type should not be 'BrandCodigo') ('Basic'…
1
vote
0 answers

How to configure value object with inheritance relationship in EF Core 5 Fluent API

I have a DDD project with an aggregate A,it has an entity list property List,and there is a value object C in entity B,the codes like this: public class A { public Guid Id {get; protected set;} public List Bs {get; protected…
1
vote
1 answer

What is the best way to create value objects?

I'm wondering how to in the best way create value objects. For example: I have value object Password class Password { private string $password; public function __construct(string $password) { $this->password = $password; } …
Racoon77x
  • 15
  • 2
1
vote
2 answers

How to convert a method of a ValueObject to SQL with Entity Framework Core 3.1

I have this value object public class ProductReference : ValueObject { protected ProductReference(){} public ProductReference(string value){} public string Value{get; protected set;} } I use it in my entity as : public class Product :…
Christophe Debove
  • 6,088
  • 20
  • 73
  • 124
1
vote
1 answer

Doctrine 2 custom entity loading and persisting

is it possible to implement a custom hydration and persistence in Doctrine 2 on a per entity basis? Doctrine 2 has some major limitations regarding value objects (e.g. collections and ids). I wonder if it would be possible to use custom mechanisms…
SpigAndromeda
  • 174
  • 1
  • 11
1
vote
1 answer

When and why to use a "ValueObject" base class (from the Microsoft Docs) in C#?

I am trying to understand the use case for ValueObject in C#, when to use and what's the need for ValueObject. I see in the documentation that it can be used when we want to initialize object and then don't want to change the properties that mean…
VR1256
  • 1,266
  • 4
  • 28
  • 56
1
vote
3 answers

Domain Driven Design - update of value objects

I'm quite new to DDD and I'm still reading about it. While reading I had some doubt about aggregates sharing some data with other aggregates. As an example, assume that I'm developing an online store, I would model an Account aggregate and an Order…
Green
  • 376
  • 5
  • 15
1
vote
2 answers

Value Object enum not being properly validated

I have a few enums in my project that will be reused across multiple models, and a few of which will have their own internal logic, and so I've implemented them as value objects (as described here @ section 5) but I can't seem to get ActiveRecord…