Answer the question
In order to leave comments, you need to log in
How should work with entity be organized?
Good day.
There is a PHP project with Yii2 and ~DDD. All data is provided to users in two languages: Russian and English.
Within the project, there is an entity Disease (for example) , tied to a specific user.
class Disease
{
/**
* @var string
*/
public $id;
/**
* @var int
*/
public $userId;
/**
* @var string
*/
public $icd10Code;
/**
* @var string
*/
public $userBasedValue;
}
interface DiseasePresenterInterface
{
public getICD10Code(): string;
public getTitle(): string;
public getUserBasedValueDescription(): string;
}
Answer the question
In order to leave comments, you need to log in
I wouldn't do that. We need to think better about the problem area. In this example, the names are incorrectly used. By definition, the book is already localized. The translators and editors of a Russian-language book are not at all those who wrote and edited the original. Here it is clearly necessary to single out the original object of copyright (original edition) and derivatives - editions and translated editions. Each edition has its own name and other characteristics.
In this case, there is no question of localization. Here is the question of a more correct analysis and modeling of the subject area.
By the way, localization through add. entities in general somehow strange to solve. This is purely a presentational layer.
Entities and aggregates are needed to implement business logic so that you cannot write unreliable and / or conflicting information to the database, and that's it!
On the screen, you display not entities and aggregates, but rather information about them ... When you think about displaying data on the screen, you should not even think in aggregates, because aggregates are units of change, not a portion for display.
Therefore, you can contact the database directly with a request to give you information, or create a separate Reading Model, and read the data through the ORM.
Create a LocalizedDisease entityIt doesn't make sense toIn general, the essence is ideally only behavior, and it doesn’t matter what data it has, that is, the principle here is “Speak and don’t ask”
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question