Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Domain driven programming and events

I'm doing some asp.net mvc coding using DDD. I have objects representing the business entities and service repositories that handle fetching and adding them. I'm new to this and as my application grows I begin to see a lot of secondary code that must run as a result of adding, deleting or changing my domain objects/data.

I'd like to make an event driven system where one action triggers other parts of code to run. For instance when I delete a user I want to be able to subscribe a number of other things to this action so they all are run when a delete takes place.

How have you coded your applications to handle these situations? How can I establish a reliable and coherent OO system for my problem? I already know about events and delegates but I'm more interested in coding techniques and nice practices.

like image 757
Roman Avatar asked Dec 05 '10 14:12

Roman


1 Answers

Thing You might want to check out are so called domain events. Basically idea is that domain model itself triggers domain specific events (e.g. CustomerRegistered) and pretty much anything You like can subscribe to them to do additional stuff outside of domain.

Udi Dahan wrote some nice articles on this: 1st, 2nd, 3rd.

Also - sample application by Szymon is quite explanatory on this.

CQRS is great, but it affects whole architecture. Might be an overkill.

like image 127
Arnis Lapsa Avatar answered Sep 29 '22 14:09

Arnis Lapsa