ThreeDotsLabs / wild-workouts-go-ddd-example

Go DDD example application. Complete project to show how to apply DDD, Clean Architecture, and CQRS by practical refactoring.
https://threedots.tech
MIT License
5.14k stars 472 forks source link

Request: Unit of Work pattern #3

Open tiero opened 3 years ago

tiero commented 3 years ago

Would be very interesting see your take on how to use the repository pattern when you need to make changes across different entities/domains.

I read about Unit of Work, that basically means implementing an intermediate in-memory structure that does trasaction-commit-rollback at the application level, without having a dependency on the underlying database.

roblaszczak commented 3 years ago

need to make changes across different entities/domains

Well, you should not do that actually in the level of the repository 😉 We will touch it in the article about aggregates and transactions, but tl;dr is that it should be done by events and should be asynchronous. If it needs to be transactionally consistent it should be one entity (or actually aggregate according to DDD nomenclature).

Stay tuned 😉

aschrijver commented 3 years ago

Looking forward to that follow-up. Isn't this also done with Saga pattern, invoking multiple commands?

PS. I noticed that the frequency of blog articles dropped off a bit. I :heart: loved the ones you wrote already. Thank you! So much better than the usual Hello World shallowness of these articles. Do you still plan to finish the series?

m110 commented 3 years ago

Hey @aschrijver! I'm really glad you liked the series. We took a short break by the end of the year, but we're back on the track now. :)

We're now finishing the "refactoring" stage (I've recently added tests in https://threedots.tech/post/microservices-test-architecture/ and Robert will post another article soon). Then, we will move to more advanced stuff, like strategic patterns. We also plan to add new features to the application in a totally new form. :)