2020年12月23日星期三

DDD paradigm. Is it possible to use a service from the Infrastructure layer on the Application Core.Domain layer

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):

  1. 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.

  2. ApplicationCore.App - a layer above ApplicationCore.Domain, contains a link to it. works with objects from ApplicationCore.Domain and uses external services through Port/Adapter. Port - For example, an abstraction of a repository, its implementation through an Adapter on the Infrastructure layer.
    interaction logic for ApplicationCore is in AppServices - for classic implementation or in Command / Request - for CQRS

  3. Infrastructure - contains a link to ApplicationCore.Domain and ApplicationCore.App. Implements the ports of the ApplicationCore.App layer

enter image description here

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

没有评论:

发表评论