开发者

Domain driven programming and events

开发者 https://www.devze.com 2023-01-29 10:51 出处:网络
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 gr

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 situa开发者_Python百科tions? 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消