Why are aggregates the command handlers? #76
-
Hi there. I'm just getting started with the framework, I'm coming from the C#/.NET world of DDD/CQRS. I am enjoying the library but I did have a question about why aggregates are handling commands and the reason for that? .NET WorldIn .NET, from my experience, the CQRS is separated from the domain/aggregates.
The benefits of this is that I can swap out any and all 3rd party dependencies, since the domain library should have no dependencies, and the business logic isn't cluttered with external calls since the aggregate has, either from it's state or from the function parameters, everything it requires to do what it needs to do. Hopefully that helps set the context for my question. It wouldn't be too much work for me to pull the business logic out of the aggregate handler but I was I just want to know the reason for the aggregate being the command handler. Perhaps in your experience you've found the command handler isn't worth it or maybe it helps with Rust lifetimes. I'm not criticizing the choice I just want to understand the reasoning. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
This doesn't isolate the aggregate as much as we'd like. The problem here is that some business logic exists in Business logic tends to grow over time, for instance if we added multiple currencies:
Very quickly we are doing a whole lot of business logic on the lookup side of things, we're no longer doing DDD right and we can't test any of this cleanly. In practice, I can tell you that these lookups change early and often in any software outside of a demo. In short, even if the business logic for your lookup is simple now, it probably won't be in the future. It's best to do any needed lookups from within the aggregate. These lookups should be calls on your aggregate's |
Beta Was this translation helpful? Give feedback.
This doesn't isolate the aggregate as much as we'd like. The problem here is that some business logic exists in
deposit_funds_command_handler.rs
, even if it is only abank_account_repository->lookup()
, and this violates DDD.Business logic tends to grow over time, for instance if we added multiple currencies: