Sorry for my English, I am writing a real estate appraisal module and decided to try writing in the DDD paradigm. I looked at examples and different articles and formed the following picture for myself (simplified):
-
ApplicationCore.Domain
- the core of business logic, contains all the necessary objects divided into 2 typesа
Entitys
- if an entity needs to be stored in a database and it is a ready-made complete business logic object.ValueObjects
- all other properties that encapsulate the behavior, are compared by the value of the fields, and are part of Entity It is very important to create only valid objects, so I create everything through factories with a validator, and the constructors are private. There should be no references to other dependencies, as isolated as possible. -
ApplicationCore.App
- a layer aboveApplicationCore.Domain
, contains a link to it. works with objects fromApplicationCore.Domain
and uses external services throughPort/Adapte
r.Port
- For example, an abstraction of a repository, its implementation through anAdapter
on theInfrastructure
layer.
interaction logic for ApplicationCore is in AppServices - for classic implementation or in Command / Request - for CQRS -
Infrastructure
- contains a link toApplicationCore.Domain
andApplicationCore.App
. Implements the ports of theApplicationCore.App
layer
Entities are independent from each other and refer to each other by keys for interaction. I kept the basic logic of the assessment system in this paradigm. But here it was necessary to add a service that receives additional information for evaluation from different sources, while in wiretapping mode. Those. Works against the background of listening to TcpIp socket
Service settings are stored in the database and change frequently - i.e. you need to introduce a new Entity
A chain is formed
DataProvider (ApplicationCore.Domain) -> IDataProviderRepository (ApplicationCore.App) -> EfDataProviderRepository (Infrastructure).
DataProvider
- must depend on ITcpIpTransport
, without it it is just a set of settings for TcpIpTransport
. Logically, DataProvider
is a service for receiving data, but it has settings and state stored in the database, i.e. you need to make it Entity
. If you make the DataProvider
dependent on the Infrastructure
layer, then ApplicationCore.Domain
will also have ports to external services, is this permissible?
how best to implement it.
https://stackoverflow.com/questions/65421849/ddd-paradigm-is-it-possible-to-use-a-service-from-the-infrastructure-layer-on-t December 23, 2020 at 05:22PM
没有评论:
发表评论