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

Can a DTO reference VO of the domain model?

Question Can a data transfer object (DTO) reference a value object (VO) of the domain model? Context In my domain, I've an importer which import aggregates from a collection. The collection is made of DTO build by a collector on which the importer…
2
votes
1 answer

Value Object as Invalid Object in asp.net core 2.1

I have been using value object in asp.net core 2.0 project, which was running properly on that project. I updated the project to 2.1 and it is giving me an error as Invalid object name 'EntityAdress'. Entity: public class Company :…
Rasik
  • 1,961
  • 3
  • 35
  • 72
2
votes
2 answers

DDD, how do you change a ValueObject?

The question refers to a situation in which you have to update/delete a valueobject. Consider this situation. You have an Order and you have Products and Products have ProductItems. Where ProductItem is a ValueObject. If you would have to update…
user9124444
2
votes
1 answer

Using value object as identifier in entity

While viewing Evans' project on sample DDD project, I notice that in the Cargo entity, Evans uses tracknumber which is an value object. Why he didn't chooses plain string tracknumber instead chooses value object for identity? Here is snippet from…
kamal
  • 739
  • 1
  • 9
  • 21
2
votes
2 answers

Why value objects implementing IEquatable in DDD?

I am new to DDD and I am working on a project where they implement DDD concepts. I know that in DDD we have Entities and Value objects, and I know in case of value objects if we need to ensure their equality we should compare the properties' values…
Waddah Rasheed
  • 239
  • 4
  • 13
2
votes
3 answers

DDD - collection of value objects

I have some middleware code which fetches a list of products from an external api. I am modelling the response and returning that response to clients of my code. Any clients of my code do not care about specifics on individual products returned:…
Marty Wallace
  • 34,046
  • 53
  • 137
  • 200
2
votes
3 answers

Can Entity be identified by all of its properties?

Question is - can Entity be defined by all of it's properties or only by it's Id. This is the example: class Wallet{ int id; Map bills; //can have only 1 bill per bill type void addBill(BillType billType, Bill bill){ …
2
votes
3 answers

DDD: status - Value Object or Entity?

I have Status public final class Status { private int code; public Status(int code) { this.code = code; } public int getCode() { return code; } } It seems that Status can be…
Teimuraz
  • 8,795
  • 5
  • 35
  • 62
2
votes
0 answers

Implementation Value Object pattern for ActiveRecord attribute

The task was allow user to view, create, edit records in different units, i.e. altitude in meters and feets, speed in m/s, knots, km/h, mi/h. I've read a lot about Value Objects, composed_of and why we should not use it and use serialize instead and…
Aleksandr K.
  • 1,338
  • 14
  • 21
2
votes
1 answer

Edit an object that as no key (Value object) in GridView (ASP.NET)

I have my main object Person with a collection of Adrresses value object like this: public class Person { public virtual int Id {get; set;} public virtual string Name {get; set;} private IList _adrresses= new List(); …
gt.guybrush
  • 1,320
  • 3
  • 19
  • 48
2
votes
1 answer

Rails Refactoring Controller and Model with too many params

I currently have a controller and model for an application form that I need help refactoring. It is a multi-view application form (hence why there is a bunch of redirects etc. in the controller). There are so many params i'm just not sure what to do…
2
votes
2 answers

Symfony forms: how to include in the Doctrine entity form a form for a Doctrine embeddable used by the entity itself

I have a Doctrine Entity that uses a Doctrine embeddable. I want to create a form to edit the Entity and the Embeddable. My Entity: /** * MyEntity * * @ORM\Table(name="my_entities") *…
Aerendir
  • 6,152
  • 9
  • 55
  • 108
2
votes
1 answer

DDD - Value object collection in aggregate results in DB impedance mismatch

Consider the case of Order/Orderline, where Orderline is an VO collection, in this case persisting Orderline to DB require a separate table with its own set of rows, being an VO this can't have a id as per DDD, how can this mismatch be addressed,…
Somasundaram Sekar
  • 5,244
  • 6
  • 43
  • 85
2
votes
1 answer

Delete orphaned shared ValueObjects?

I'm still trying to understand DDD. Let's say I have an immutable VO PresentationSlide. Because it is immutable it can be easily shared and used by different entities. But what happens if I try to map this to a database. In EntityFramework I could…
krombi
  • 504
  • 1
  • 4
  • 15
2
votes
0 answers

Unit-testing a functional core of value objects: how to verify contracts without mocking?

I wanted to give the Functional Core/Imperative Shell approach a shot, especially since Swift's structs are so easy to create. Now they drive me nuts in unit tests. How do you unit test a net of value objects? Maybe I'm too stupid to search for the…
ctietze
  • 2,805
  • 25
  • 46