Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [value-object]

The tag has no usage guidance.

0
votes
2answers
148 views

ValueObject - too wordy?

So, I'm having some value objects in my domain, and when I'm using them in one of my builders it looks like this: .withSomething(Id.of(123), Specifiers.of(MySpecifier.of("233"), MySpecifier.of("23423"...
6
votes
4answers
267 views

Passing around large value objects vs converting to smaller value objects

Let's say I have a project that needs to do the following: Multiple calls to read from the database where each call is a different query and returns back a value object (just has getters/setters). ...
0
votes
1answer
135 views

Should entity properties be represented by a value object?

I read somewhere that one should be generous in creating value objects for entity properties that are part of the class API. So I did that with my project entity/aggregate, but it still looks weird: ...
0
votes
2answers
106 views

DDD domain identifier implementation should be ValueObject?

In DDD we defined domain's identifier as ValueObject. Regard here How ever in last project I implement those ID like so public struct UserID { public readonly string GUID; } public struct ...
0
votes
1answer
66 views

Dealing with Complex Value Objects

I am working with Martin Fowler's definition as a working base. I have a class called Condition that I am having trouble properly classifying. What makes me think this might be a value object: A ...
2
votes
4answers
5k views

Is it really a bad practice to mock a POJO (value object) if you don't care about what it contains?

In the advice of Mockito about how to write good tests, it is written that we should not mock value objects (https://github.com/mockito/mockito/wiki/How-to-write-good-tests#dont-mock-value-objects). ...
2
votes
0answers
117 views

Should I use value objects creating them via factory method and have only getters or just write DTO's with constructor and getters/setters?

I've been using the APIs of a ticketing service which returns arrays of data more or less complex based on the entrypoint called. In order to simplify my life when consuming such API I wrote some ...
2
votes
3answers
157 views

Is there anything wrong with making nullability of a reference type explicit by wrapping it in a value type?

When I program in Java, I make all nullability explicit; that is, an instance of Foo is assumed to be non-null, and if I want it to be null, I use a @Nullable annotation (or better, Optional<Foo>...
2
votes
1answer
219 views

Must constructors of value objects not do work, even when class invariants prescribe so?

Today I had a discussion with a colleague. It is my understanding that a class has the responsibility to ensure that its objects have a valid state when interacted with from outside the class. The ...
1
vote
4answers
1k views

immutable string in array, reference type vs value type

Trying to understand strings better in C# Are these assertions correct? string is immutable string is reference type but behaves like value type For these code samples... string x = "one" (...
1
vote
2answers
110 views

Name for Keeping Multiple Copies of a Variable

There is a bad practice in software engineering where a single piece of data is held by value in multiple places. For example, in an FPS, the location of the player could be held by the AI class, the ...
4
votes
0answers
3k views

Option<T> functional type implementation and scenarios

Have you ever being implementing Option<T> functional type? It is discussed here: https://app.pluralsight.com/library/courses/tactical-design-patterns-dot-net-control-flow/table-of-contents ...
7
votes
3answers
2k views

C++ returning persistent objects

I'm currently trying to learn best practices in C++ after coming from a C# background. I understand that there are three ways of handling objects: By value (objects are copied or moved when passed ...
9
votes
2answers
397 views

Should well-known business ID of an entity be represented with a dedicated type in DDD/OOP?

In practical terms it means using an custom (immutable) class over a string or some other primitive type. Examples: Publishing: International Standard Book Number. Finance: International Securities ...
0
votes
1answer
411 views

VO to Entity Conversion

In our application we have multiple layers. UI -> This can be JSP/ JSON result of the API Controllers -> as in MVC Services -> perform single business operation per service DAOs -> Data Access ...
-1
votes
2answers
202 views

Getters with data conversion in Java VOs [closed]

I am working on a standard Spring application where DAO layer returns entities to service layer and service layer returns VOs to other services and controllers. In a certain scenario, we have a VO ...
0
votes
1answer
314 views

domain driven design value object behavior

I recently finished Steve Smith and Julie Lerman's excellent Pluralsight course on Domain Driven Design, and I'm applying the training to a project. I have what I think is a good candidate for a value ...
2
votes
3answers
1k views

Overriding equals() method in Java

Short question: Why does Java allow overriding equals(), why is it not final? I am reading Effective Java 2nd edition by Joshua Bloch. I am a bit baffled by the conclusion that There is no way to ...
3
votes
2answers
7k views

How should blank/empty value objects be instantiated/structured?

I was wondering... what is considered the best practice to instantiate blank value objects? (in Java) E.g. Assume we have some value object class Foo, that could be blank. Would creating methods ...
8
votes
3answers
2k views

In domain driven design, how do I convert a database table with a primary key into a Value Object?

Lets suppose there's a database schema defined like this: Person.mail_address_key ----- Address.address_key Person.billing_address_key ----- Address.address_key A Person has a mailing address and a ...
2
votes
2answers
487 views

DDD - If an object is saved as a whole to the database, is it per definition an entity, or is it still possible that it is a value object?

I'm learning about Domain Driven Design and struggling with the question if a particular object should be handled as entity or value object. All possible surname prefixes are kept in a database table....
4
votes
1answer
1k views

Use a custom value object or a Guid as an entity identifier in a distributed system?

tl;dr I've been told that in domain-driven design, an identifier for an entity could be a custom value object, i.e. something other than Guid, string, int, etc. Can this really be advisable in a ...
4
votes
2answers
3k views

DDD and the persistence of value objects; must we denormalize?

I've been reading up a lot on Domain-Driven Development, and I came to the question of how to preserve lack of distinct identity with value objects (VOs). While in the DDD world, this is a requirement ...
2
votes
1answer
84 views

A good name for ValueObject that contains database update/create column values [closed]

We all know these fields, database admins so like to add: UserCreated & DateCreated UserUpdated & DateUpdated They need to be displayed in the UI so I want to put them in some ValueObject ...
2
votes
2answers
306 views

Shouldn't Location be a Value Object?

Eric Evan's DDD book, Cargo Shipping Example, pg. 168: Location Two places with the same name are not the same. Latitude and longitude could provide a unique key, but probably not a very ...
8
votes
1answer
2k views

Unique Value Object vs Entity

Trying to convert some entities into value objects I am stuck in a case where what seems a value object must be unique within an aggregate. Suppose we have a Movie entity which makes the root of an ...