简体   繁体   中英

DDD implementation - repository and factory

I write in java and try using DDD.

  1. I have domain model with interface for repository, repository has interface where is implemented in infrastructure layer (IoC).
  2. I would like that only aggregation roots class and interfaces had package scope public. Entity, domain service, VO should had package scope private.

App schema (Interfaces is controllers, GUI etc.)

My question is:

  • How save data to database from aggregation root without getters. I would like have only clean buissnes behavior. Maybe my aggregation root should create DTO object?(but is smell)
  • Factory should be in domain package, application or should have interface in domain package?

How save data to database from aggregation root without getters. I would like have only >clean buissnes behavior. Maybe my aggregation root should create DTO object?(but is smell)

May be you are looking for ports-and-adapters architecture pattern.

Usual approach - place business and infrastratucture code in same package but in different modules

You even can make your AR non-public without public getters/setters.

Example:

https://github.com/ddd-by-examples/factory

look at

Examples of Domain Model in code: aggregate ProductDemand entity DailyDemand

in description - ProductDemand and DailyDemand not public, placed in demand-forecasting-model module at package io.dddbyexamples.factory.demand.forecasting

Now look at package io.dddbyexamples.factory.demand.forecasting in module demand-forecasting-adapters and you will see infrastructure implemmentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM