Domain Based Programming and Events

I am using asp.net mvc encoding using DDD. I have objects representing business objects and service repositories that handle fetching and adding them. I am new to this, and as my application grows, I begin to see a lot of secondary code that should run as a result of adding, deleting, or modifying domain objects / data.

I would like to create an event driven system where one action launches other pieces of code to run. For example, when I delete a user, I want to be able to sign a number of other actions for this action, so that all of them will be executed upon removal.

How did you code applications to handle these situations? How can I create a reliable and consistent OO system for my problem? I already know about events and delegates, but I'm more interested in coding methods and good practices.

+5
asp.net-mvc domain-driven-design
source share
1 answer

Thing You can check the so-called domain events . Basically, the idea is that the domain model itself triggers domain-specific events (e.g. CustomerRegistered ), and almost anything you like can subscribe to them to do extra things outside the domain.

Udi Dahan has written some good articles about this: 1st , 2nd , 3rd .

Also - an example application from Szymon is understandable.

CQRS is great, but it affects the whole architecture. Maybe bust.

+8
source share

All Articles