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
3
votes
1 answer

Value objects with Dapper

I have an entity with an aggregated value object, like this: public class Address { public string Town { get; set; } public string Street { get; set; } public string Region { get; set; } ... } public class Contact { public Int32…
petrux
  • 1,743
  • 1
  • 17
  • 30
3
votes
3 answers

Shouldn't in the following model an Address be a Value Object?

From How are Value Objects stored in the database? : Assume that a Company and Person both have the same mail Address. Which of these statements do consider valid?    1."If I modify Company.Address, I want Person.Address to automatically get those…
user1483278
  • 929
  • 1
  • 9
  • 17
2
votes
1 answer

DDD - How to use Shared Kernel with multiple bounded contexts?

Shared Kernel describes the relationship between TWO bounded contexts. I haven't found any helpful information how to efficently handle shared objects between multiple bounded contexts. We use value objects instead of primitive types. Entity Ids are…
M. Koch
  • 525
  • 4
  • 20
2
votes
1 answer

Problem Changing the value of nested ValueObject using C# 10, .NET 6 and EF Core 6

My Aggregate is like this: public class Order : AggregateRoot { private readonly List _items = new(); public DateTime Date { get; set; } public IReadOnlyCollection Items => _items; public void…
2
votes
1 answer

EF Core Value Object Owned by many

I use a value object to represent the Price public record Price(decimal Amount, string Currency); Then I have two entities with a price public class Item { public Price { get; private set; } // rest of properties } public class…
2
votes
1 answer

Business logic inside of value object

I think value object should not have business logic. That maybe confused other programmers. for exmaple, public class PersonVO { private String name; private int age; public void somethingBusinessLogic() { // Do very…
sb0321
  • 53
  • 1
  • 8
2
votes
2 answers

EF Core - ValueConverter or OwnedType for simple ValueObjects?

I use value objects to encapsulate validations like maxLength. This is an extract of a sample class without factory method and validation: public class CallingName : ValueObject { public string Value { get; } public const int MaxLength =…
2
votes
2 answers

how to create index for value-object member using c# EF fluent api

I have entity that contain value-object with name IdCard like this: public class UserProfile : BaseEntity { public byte Gender { get; private set; } = 0; public int? BirthDate { get; private set; } public IdCard IdCard { get; set;…
sos5020
  • 379
  • 1
  • 3
  • 10
2
votes
2 answers

Is it allowed to modify value of the Value Object on construction

Assuming that I want that following Value Object contains always capitalized String value. Is it eligible to do it like this with toUpperCase() in constructor? class CapitalizedId(value: String) { val value: String = value.toUpperCase() //…
Roman T
  • 1,400
  • 5
  • 18
  • 31
2
votes
1 answer

How can I use a simple ValueObject as String in GraphQl

I want to use value object or string object in my project (DDD, Hexagonal, POO no question). I can work perfectly in most cases but I couldn't find a way to work with it in Api Platform GraphQl. I've tried Type, Normalizer and some other ways…
2
votes
2 answers

Generating ActionScript value objects from an xsd schema

Are there any tools available for transforming types defined in an xsd schema (may or may not include other xsd files) into ActionScript value objects? I've been googling this for a while but can't seem to find any tools and I'm pondering wether…
Marcus Stade
  • 4,724
  • 3
  • 33
  • 54
2
votes
2 answers

Extra join in query for value objects in Entity Framework Core

In Entity Framework Core 3.1.3, I have used the value object feature. In the query side, the problem is an extra left join exists in T-SQL. This extra join results in problems in terms of performance. In the following code Student is an Entity type…
2
votes
0 answers

Entity Framework Core OwnsOne unnecessary JOINS on same table

Entity framework core seems to create very complex queries when configuring value objects with OwnsOne on the same table. Entity: Restaurant.cs public class Restaurant : Entity, IAggregateRoot { public RestaurantId Id { get; private set; } …
Nando
  • 813
  • 2
  • 8
  • 18
2
votes
0 answers

Can value objects in Clean Architecture have a dependency on an interface

I decided to code my new project in Clean Architecture, with which I'm not very familiar. I'm using this template https://github.com/JasonGT/CleanArchitecture I have an Entity Withdrawal.cs which has a BTCAddress ReceiveAddress property: public…
Reath
  • 491
  • 5
  • 16
2
votes
1 answer

Is JPA Embeddable a Value Object and Why Can't it Represent a Table

PROBLEM: I have read-only data in a table. Its rows have no id - only composite key define its identity. I want it as a Value Object (in DDD terms) in my app. RESEARCH: But if I put an @Embeddable annotation instead of @Entity with @Id id field,…
Zon
  • 18,610
  • 7
  • 91
  • 99