Live data from Hacker News

Show HN: Learn what DDD, CQRS, and event-sourcing are all about

docs.wolkenkit.io

51–60 of 86 posts

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#51

The DDD/CQRS/ES topic appears on Hacker News every so often, and never fails to stir a strong debate. In fact, I was going to "Show HN" an Event Sourcing library I open sourced yesterday, but I guess I'll wait until everything dies down a bit :-) I believe that the core principles of DDD/CQRS/ES are flawed and are the cause of a lot of pain. If your team plows forward and ignores the pain, you will have a bad experie…

hi - could you explain the implementation of this "Materialized views for each aggregate are kept in-memory at all times" ? i have been considering a heretical flavor of CQRS/ES as well, where the command returns data.... and i synchronously build the latest state before I return (rather than building through the whole event stream).

when you say "materialized views" - do you really mean the current state of an Order for example ? and by "in memory", is it being persisted to a database ?

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#52

Earlier quoted context omitted.

It really depends on the application. Eventual consistency means that eventually, the databases will be consistent. Some bank transactions, for example, do not have that luxury because it might allow 2 possible answers to the same query if the eventuality has not been met. Some trading transactions don't have that luxury either because the milliseconds that you waited for the consistency a stock might have changed it…

Banks have daily lag (pending transactions). They also stop business in the evening and resume in the morning to process all these items. That isn't feasible in a lot of scenarios. Rarely do you have an up to the microsecond view of the markets (unless you are located appropriately and pay significant amounts of money). There is always a delay in the information's accuracy and relevancy.

This "lag" is there mostly because historical reasons, not technical.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#53
post #42

Earlier quoted context omitted.

Maybe I'm not as much of a heretic as I thought I would be :-)

Starting from fresh these days I would use something 2 way for commands, queries like HTTP REST. But a messaging system for events. If i'm using event sourcing use a dedicated event sourcing database with catchup subscriptions etc

> a dedicated event sourcing database with catchup subscriptions etc

Can you recommend any?

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#54
post #52

Earlier quoted context omitted.

Banks have daily lag (pending transactions). They also stop business in the evening and resume in the morning to process all these items. That isn't feasible in a lot of scenarios. Rarely do you have an up to the microsecond view of the markets (unless you are located appropriately and pay significant amounts of money). There is always a delay in the information's accuracy and relevancy.

This "lag" is there mostly because historical reasons, not technical.

I'd rather argue they are there for "domain" reasons. For one, banks often re-order transactions. I know my bank will process deposits first, then debits for the day. This way you are less likely to incur overdraft fees. It's also to fight fraudulent transactions. Although with the move to "real time" debit processing (which is actually two batch jobs a day) they are placing limits on the types of transactions that can be processed.

A domain that can't handle any delay in consistency is atypical in my experience. Either way you can do DDD/CQRS without eventual consistency.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#55
post #49

Earlier quoted context omitted.

> Often yes, people do starting adding queues, materialised views to CQRS which can make it complicated. You don't say?? You don't say?? Sorry to be flip, I hope you can tell that I've been burned. Badly. Thanks for your detailed response. You obviously care and are not a stupid person nor do you come off sounding vain. But, you're not selling me on CQRS at all. What you've described is just classifications and organ…

"it's a realtime, live multiuser system where all commands are queued, transformed to system events, and those events are committed to log (via another queue, we have to synchronize after all) that stretches back into time. We can replay those events, rewind time, events are merged ..." And it goes on and on into the stratosphere of architecture astronaut-hood..." But that isn't CQRS. That's event sourcing, a complic…

Ah, well CQRS is only justifiable when you're selling the work if you couple it with the ES, and the more complex it is, the better the sales job and the budget. It's like peanut butter and jelly.

My main point in replying to you was that you weren't selling me on whatever brand of CQRS you think you've got. Why? It seems like you're atomizing your business logic into a fine mist, why is that good? And you still haven't talked about all the myriad transforms you do: where's the payoff? Does YAGNI apply in your case?

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#56
post #42

Earlier quoted context omitted.

Starting from fresh these days I would use something 2 way for commands, queries like HTTP REST. But a messaging system for events. If i'm using event sourcing use a dedicated event sourcing database with catchup subscriptions etc

> a dedicated event sourcing database with catchup subscriptions etc Can you recommend any?

Greg Young's Event Store[1].

[1] https://geteventstore.com

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#57
post #23

Earlier quoted context omitted.

Well that's the entire problem, you are not the one making the requirements, the solution of the problem does... You can't eat dinner before you have made it. Edit: I would argue that you can't write a system which is open (several domains) and believe that you will have entirely independent events throughout the system and claim that your system will be "bugfree"/correct.

I could be missing something but I feel like you are inventing an impossible scenario. You may not be making the requirements, but the requirements have to be technically feasible. CQRS/DDD give you a lot of flexibility on where to choose your boundaries/aggregate roots and these are designed around the business/requirements. If you can give a valid scenario where this model breaks down but others would succeed I'd b…

It's not requirements by "what to do" but the requirements of "what we need to make "what to do"" work. For example if you are going to add two numbers you have to use some sort of arithmetic to solve that problem, right? If you fail using arithmetic to solve it you will not solve the problem and your function will do something else. The requirement of solving in this particular case will be "use arithmetic".

So this means for your problem to be correct you have to use the correct tools to solve that problem. If you think that everything (all problems) can be decomposed to independent events, which per definition can happen in any order, you can safely use ES. But if they have any dependency on each other you need ordering, and ordering in a distributed system is a hard problem. And add to this is that somewhere some guy from the business will come up with an actual requirement where you must synchronize and if you then have solution which inherently where this is not possible you are screwed.

This is true for both reading and writing in that system. Most problems are dependent otherwise it won't solve/do anything, there are usually a purpose with most systems.

While you can have systems where the events are entirely independent, structurally independent, such as JS event loop and red/blue methods (just locally independent), or it doesn't matter like plain application logs, this is rarely, if not impossible between domains if you want a correct system since you won't know if all events have arrived yet to tigger another event, if there's any dependency between them, which there will be between two domains.

DDD is good but not in this context, CQRS is trying to partially to solve above problems, but not needed and is just bloating. It does fit better with C# since the (weird) implementation of async/await and potentially with JS for the same reasons. ES do have their use cases where they fit very well but not with the practical impacts of DDD.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#58
post #52

Earlier quoted context omitted.

This "lag" is there mostly because historical reasons, not technical.

I'd rather argue they are there for "domain" reasons. For one, banks often re-order transactions. I know my bank will process deposits first, then debits for the day. This way you are less likely to incur overdraft fees. It's also to fight fraudulent transactions. Although with the move to "real time" debit processing (which is actually two batch jobs a day) they are placing limits on the types of transactions that c…

They are there because they are used to think that way. It's conways law written all over it... There's no actual reason for them to do it. They replaced their paperwork with a system that does the same thing. Fraudulent transactions can you find without the need of summarizing it.

Yes you can do DDD/CQRS without ES but CQRS is not needed, it's just a technical construct not solving any verifiable problem. DDD on the other hand is more sane and to some extend, verifiable.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#59
post #49

Earlier quoted context omitted.

"it's a realtime, live multiuser system where all commands are queued, transformed to system events, and those events are committed to log (via another queue, we have to synchronize after all) that stretches back into time. We can replay those events, rewind time, events are merged ..." And it goes on and on into the stratosphere of architecture astronaut-hood..." But that isn't CQRS. That's event sourcing, a complic…

Ah, well CQRS is only justifiable when you're selling the work if you couple it with the ES, and the more complex it is, the better the sales job and the budget. It's like peanut butter and jelly. My main point in replying to you was that you weren't selling me on whatever brand of CQRS you think you've got. Why? It seems like you're atomizing your business logic into a fine mist, why is that good? And you still have…

Well each command is a use case. Each use case can be tested independently without having setup controllers and their dependencies, or big service layers and their dependencies.

Plus I can run the usecases from a console frontend for quick testing without much setup.

I don't really do any transforms other than mapping domain objects into the dB or database results into a query result.

Why do I need it? Because I practise DDD, and domain objects are not designed for queries. To populate a single view you have pull multiple domain objects from repos. This can be slow and adds complexity.

Query objects allow me to query the database using standard SQL or stored procedure and put the output into query result using only a single query. These queries can as complicated and optimised as they need to be.

Meaning I can avoid all DDD abstractions that I don't need for querying, but I do need for enforcing complicated business rules on the command side.

Re: Show HN: Learn what DDD, CQRS, and event-sourcing are all about

#60
post #2

Run away. Run far, far away from CQRS and Event Sourcing.

This comment isn't very helpful. Still, it should be noted that Fowler warns that CRQS adds significant complexity and advises great caution about using it. See https://martinfowler.com/bliki/CQRS.html

Greg Young also cautions "Do not tell me you've built an event sourced system"* (or something along those lines) meaning that you should be careful to apply the pattern only to the part(s) of the system that makes sense (due to the increased complexity of ES)

* I think it's in this talk https://www.youtube.com/watch?v=JHGkaShoyNs

Post reply on HN