|
|
|
|
|
by karmajunkie
4442 days ago
|
|
They're equally coupled. In one system, the coupling flows outward from the business process—the business process must know about the other services. In the other, the business process is domain-driven and knows nothing about processes that are driven by the events that happen within that space. The outer processes (e.g. the fraud service) know about things that happen in the domain (or rather, what messages the domain contract will send). I've actually written a fraud detection system this way. Worked beautifully. Within the service boundary I suppose you could say it was driven imperatively, but I don't think that's what you're talking about. > Business process changes a lot. Would you rather update all actors' bindings when this happens, or just one supervisor? In point of fact, a lot of business processes never, ever change. The way they're handled may change, and at that point, I'd prefer for that concern to be nicely packaged into a service or actor or listener or whatever you want to want to model it with where my domain logic isn't concerned with it at all. And if my domain does change? I shouldn't have to change a fraud detection service at all. And in neither your model nor the OP's would I have to. > And not... The business process changes? Change all the things! Because it's not just a matter of whether CancelOrderActor is bound to the FraudEvent by subscription. I fail to see how his process has this problem and yours magically doesn't. You're making a lot of hay out of whether his "reactive" events or your "imperative" messages are better or worse, but they're the same thing: sending messages. The only difference is whether broadcast is better than a direct message sent to a unit. |
|
No, that's not the only difference. Notice that I have 4 actors, only one is burdened with knowing how the process works. Here's what the other 3 actors see from their PoV:
- PaymentActor gets "process payment" event.
- FraudCheckActor gets "check for fraud" event.
- CancelOrderActor gets "cancel order" event.
This is what I call decoupling. 3/4 of your system is completely isolated from each other and reusable in different business processes. And the one actor who is "burdened" with knowing about the process (OrderActor) is in fact, responsible for the process (and you can open its code in one place, read it, reason about it, and change it in one place, not all over the graph).
And his model:
- PaymentActor gets "new order" event.
- FraudCheckActor gets "payment complete event" event.
- CancelOrderActor gets "fraud detected" event.
Those 3 processes are coupled with each other, as they need to interpret each other's events.
If you want to move to another system where the fraud check doesn't happen right after the payment, you need to edit the FraudCheckActor's "reaction" to that event.
In my case FraudCheckActor is only reacting to the "check for fraud" event and so it doesn't have to have its reaction code edited.
There's nothing "magical" about it, just better concern isolation. If you still see this as the same, that's all I could do to explain things :)