Usecase for domain event?

89 views
Skip to first unread message

Jeroen De Dauw

unread,
Oct 18, 2016, 9:03:51 AM10/18/16
to Clean Code Discussion
I have an application that deals with donations and follows the Clean Architecture.

When a donation comes in, it might be flagged for moderation. If it is not, the donation is considered accepted and a confirmation of acceptance is send to the user. A separate application gets the donation information and provides a moderation UI. It is this application that knows when a donation that got flagged for moderation gets accepted. Somehow this moderation application needs to notify the main donation application so it can send the confirmation email (and do whatever else it deems necessary).

There are two complications: (1) The donation application has no event system. (2) The two applications share persistence due to legacy reasons, so when the donation app retrieves a donation that got accepted in moderation, its state will already indicate this.

What I started doing is adding a HandleDonationAcceptedNotificationUseCase. This UC can then invoke the code that needs to happen when the "donation accepted" (conceptual) event occurs. This can then be changed if we introduce a real "donation accepted" event, so the UC just creates and fires the event. Somehow this seems strange though, since all it does is fire that event, and it's not the only place that can happen.

What are the typical approaches you'd use in such a scenario? Do you see any concrete problems with or have suggestions for modification of the approach I described?
Reply all
Reply to author
Forward
0 new messages