Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Onion Architectures, persistence and notifications

I am studying Onion Architectures and I have a point.

Onion Architectures aim at isolating the Domain from technological artifacts. Therefore, the guideline is to let the Data Access Layer (DAL) reference the Domain Layer (BL). This way, I should be able to transform entities into storage artifacts. Referencing the BL should probably give me a "snapshot" of my Domain, but without a change-tracking system I will loose all chronological events to know whether inserting, updating, or deleting items in the data-store, to be able to correctly rehydrate the model afterwards.

Do Onion Architectures always need some change-tracking systems, or even something like an event-store ? Am I missing any other pattern ?

like image 251
Rénald Avatar asked Dec 02 '25 09:12

Rénald


1 Answers

Does the domain layer know when it needs persisting?

For example i might have a new/update customer screen that saves a new customer when i press finish. At that point i don't care about change tracking, i want to just store everything that i have. and my DAL can figure out if i already have a customer with the same name in the database or not (if it should emit insert or update queries).

Same thing applies to to an event store. And event store if an technical implementation if your domain cares about events, being able to undo event, etc etc,

What might happen is that your Domain Layer always consist of a complete in memory up live mutating system. In that case there isn't even a snapshot.

The onion architecture just describes to separation of artifacts. Which artifacts they are will really depend on particular requirements.

like image 184
Batavia Avatar answered Dec 04 '25 10:12

Batavia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!