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
11
votes
2 answers

DDD - Value Objects Vs. Entity Objects

I'm new to DDD and trying hard to understand some of the concepts. How do you determine in your domain what objects are Entity objects and which ones are Value objects, and how exactly are they treated differently?
Micah
  • 111,873
  • 86
  • 233
  • 325
10
votes
8 answers

Difference between Value Object pattern and Data Transfer pattern

In which scenario can I use those design patterns in n-tier architecture?
suri
  • 131
  • 1
  • 1
  • 3
10
votes
3 answers

Null value objects in NHibernate

I have a person entity containing an Address as a value object: public Person() { WithTable("Person"); Id(x => x.Id); Component
(x => x.Address, a => { a.Map(x => x.Address1); a.Map(x => x.Address2); …
James Allen
  • 6,406
  • 8
  • 50
  • 83
10
votes
1 answer

How can I create a Required Owned Type with Entity Framework Core 3.0

I'm struggling creating a non-nullable/required Owned Type with Entity Framework Core. I'm using EF Core 3.0 against PostgreSQL database. My value object: public class PersonName { public PersonName(string name) { …
10
votes
1 answer

DDD: Can a Value Object have lists inside them?

I'm not well versed in domain driven design and I've recently started created a domain model for a project. I still haven't decided on an ORM (though I will likely go with NHibernate) and I am currently trying to ensure that my Value Objects should…
9
votes
2 answers

What is an example of a Value Object in PHP?

I have read plenty of C# examples of Value Objects, and I understand that it is an "object" that is identified by it's values. If a value changes, the object is "new". However, that doesn't seem to make sense when it comes to PHP...either that, or…
johnnietheblack
  • 13,050
  • 28
  • 95
  • 133
9
votes
1 answer

How do the `EqualOperator()` and `NotEqualOperator()` methods work in this `ValueObject` implementation (Microsoft Docs)?

In Domain Driven Design, we're introduced to the concept of a ValueObject, where objects don't carry an identity. Microsoft have provided an implementation of their ValueObject in their Microservices series, where they override Equals() so that two…
Matt Griffiths
  • 1,142
  • 8
  • 26
9
votes
3 answers

DDD: Instantiate Value objects inside Aggregate or pass it as parameter?

When creating aggregates, should we create value objects inside aggregates, or we should pass already created value objects to ctor or factory. public Booking(DateTime arrivalDate, DateTime departureDate) { …
Robert
  • 3,353
  • 4
  • 32
  • 50
9
votes
2 answers

Aggregate values in REST APIs

I am working on an application which requires some double entry bookkeeping. Currently there are two endpoints /account /transaction While /account handles general data of the accounts, /transaction handles transactions for deposits/withdrawal.…
mrroboto
  • 91
  • 2
9
votes
3 answers

How to use reusable validation in a ValueObject

I'm trying to get my head around combining some techniques. It seems good practice to never make it possible to create a ValueObject that is not valid. The ValueObject constructor therefor should fail whenever the provided content is not good enough…
8
votes
3 answers

DDD: how to keep a complex value object immutable?

I'd like to model an Address as a value object. As it is a good practice to make it immutable, I chose not to provide any setter, that might allow to modify it later. A common approach is to pass the data to the constructor; however, when the value…
BenMorel
  • 34,448
  • 50
  • 182
  • 322
8
votes
3 answers

Domain Objects and Value Objects - are they equal?

By looking to the example of a Domain Object into Zend Quickstart tutorial, and other examples considering a DAO/VO patterns, they both seem to be very similar. Can we deduce that to say "Value Object" is the same as to say "Domain Object" ? If…
MEM
  • 30,529
  • 42
  • 121
  • 191
8
votes
1 answer

Golang and DDD domain modeling

I've been studying domain-driven design lately and must say this type of architectural design triggers something in me. When I try to apply its concepts to my Go project I've encountered some obstacles. Following are some example methods, but I'm…
Karl Andresen
  • 503
  • 1
  • 6
  • 15
8
votes
1 answer

Entity Framework Core 2.1 - owned types and nested value objects

I'm learning DDD and the tutorial I'm currently following is implemented using NHibernate, but since my lack of experience with it I've decided to go through the course using EF Core 2.1. However, I'm currently a bit stuck with the following: I…
8
votes
1 answer

How to share validation between Forms and Value Objects in Domain Driven Design?

#1. Validate EmailAddress on the Form I have a backend form class with an emailAddress property that has validation logic so that I can return an error message back to the user. I validate all form inputs with something…
prograhammer
  • 20,132
  • 13
  • 91
  • 118
1
2
3
21 22