M
M
microf2019-06-10 13:54:23
Problem-Based Design
microf, 2019-06-10 13:54:23

Make Entity or Value-object?

Good afternoon. There is a standard Entity describing the Organization

class Organization {
public function __construct(Name $name, Address $address, Phone $phone) 
{
$this->name = $name
...
}

}
Name, Address and so on are the ValueObject in which I validate the incoming data
Assert:notEmpty($country);
Assert:notEmpty($city);
Assert:notEmpty($street)

So I save "Россия", "Москва", "Солнечная ул", "15", "115033"
But now there is a new rule that you need to do a search for organizations in the city, and this is exactly the right search.
(Yes, of course, such things should be discussed in advance)
What to do in this case?
Make a separate City entity and save it in the previous version
"Россия", "CityID", "Солнечная ул", "15", "115033"?
Or leave it as it is and do a search for the text "Moscow" in the database later? In this case, I need to somehow validate the city for its presence in some "list of cities in Russia" by entering the city? I can do this in the infrastructure layer, of course, but somehow it won’t be completely wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question