Answer the question
In order to leave comments, you need to log in
What is Domain object and Subject area, in simple terms?
I started to study OOP and I often see the mention of the Domain object and the Subject area . I see them especially often in the context of the Repository . Because I am not yet ready for a complete immersion in the books of Evans and Vernon. Many articles were read and, selectively, chapters from these books. Unfortunately, I did not quite understand, even superficially, what they are. I will describe how I understand these concepts, I will ask you to correct me or supplement.
Subject area - represents a part of the real world that should be implemented in our system.
Example:
class Account
{
private Id $id;
private Balance $balance;
private Status $status;
private array $clients;
}
class Account
{
private Id $id;
private Balance $balance;
private Status $status;
private array $clients;
public function addClient(int $id);
public function removeClient(int $id);
public function rechargeBalance(int $amount);
}
Answer the question
In order to leave comments, you need to log in
The subject area is the set of all entities and their relationships within the context.
For example:
Within a store, these are buyers, sellers, products, prices, discounts, suppliers, the process of selling, coming to the warehouse, returning, etc.
Within the discord, these are users, servers, rooms, groups, access rights, the processes of joining a server, entering a room, paying for nitro, writing a text message, etc.
In general, this is everything that your manager understands and nothing that he does not understand. The subject area does not include, for example, where exactly you store data - in mysql, in files, you receive and save them via API or store them in redis. But the abstract entity "storage" is included. It is also the interface of the repository. A repository is a pattern that hides the implementation of a specific repository and that operates on domain model objects - domain elements, as if they were stored in your RAM. For example, a repository might have methods
users.getByID(1234), users.save(user), users.getByEmail("[email protected]")
etc. The implementation of the repository determines where exactly this user will be saved or where it will be downloaded from. In one table or in several. Whether the data will be normalized in the RDBMS or denormalized. It is here that you can implement writing to master, and reading from replicas. Or encoding in msgpack and transferring it via API somewhere. Or via gRPC. Because the subject area should not be overloaded with implementation details of storages. {"category1": ["foo", "bar"], "cat2": ["foo", "hello", "world"]}
. It is so convenient to represent them at the level of the subject area, I can communicate with the customer about this structure. But in monge they are saved as['category1%%foo', 'category1%%bar', 'cat2%%foo', 'cat2%%hello', 'cat2world']
, because it's easier to index them and search them faster. But this is hidden in the implementation of the repository, the domain area does not know anything about it. This gives many advantages at once: Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question