Mroziqella
Mroziqella

Reputation: 3

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:

Upvotes: 0

Views: 1376

Answers (1)

aelor
aelor

Reputation: 60

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

Upvotes: 1

Related Questions