ketan-gote / ddd-example

Domain Driven Design. Examples focuses on key concept of ddd like Entities, Aggregate root, Repository, Value Objects & ACL.
104 stars 35 forks source link

Is it the domain layer coupled with database stuff? #1

Open antunesleo opened 4 years ago

antunesleo commented 4 years ago

Hello Ketan,

Found my self reading the blue book and looking for implementation examples, so I found your repository. I have a question for you. In the entity order (order_ddd_example/src/main/java/com/metamagic/ddd/entity/Order.java), Is it coupled with database stuff, right?

@PrimaryKey
@Persistent(column = "orderid", customValueStrategy="uuid")
private String orderId;

Shouldn't this stuff be in another place? I do ddd in the company I work for. We have to adapt a lot of the ddd stuff, but it worked for us. For study purposes, I'm trying to find a solution closer to the book. I found yours and it helps me a lot, specially in the repository part. but I didn't understand why you put this together.

marccollin commented 3 years ago

Everything in the domain layer should not use specific technology stuff: spring, orm..according to ddd

it's sure if your domain entity it's tempting to have the same structure in the db... otherwise, you need to create other object who will be the real mapping to the db...

damnms commented 3 years ago

yeah and in the "api" package is spring stuff... thats a very technology driven approach and not really ddd

i'd like to have a "no-technology-model" that holds ONLY business logic, and not mixed with technology from third-parties. to achieve that, just split each package in its own project and see if it still compiles wihout all that third party deps.