Designing Event Types and Event Handlers is hard work
...
I think the lesson here is that an enumeration of application-defined Event Types is a weak language for describing change.
I'm not sure I understand the point about the events being a weak language for describing change. You literally capture all the changes within events. It's the only language for describing changes that actually matter.
To follow your example - if there's a "exceptional reputation change" event missing in the language - it has to be introduced which will force all the consequences on the downstream business to be considered. If this seems like a constraint - event sourcing might not be the proper solution.
If you find that designing events is hard work - you're doing the right thing! This means you probably are learning a lot about the domain.
Imagine your domain consists of a dot moving on a square 2-dimensional grid. You could imagine 2 events systems (2 "languages") for describing each state transition:
- {MoveUp, MoveDown, MoveLeft, MoveRight, MoveUpLeft, MoveDownLeft, MoveUpRight, MoveDownRight, DontMove}
- {MoveBy(x, y)}
Both event systems describe all transitions in the domain, yet most people will probably agree that 2. is superior to 1. - 2. more expressive, and 1. yields a lot of over-specificity. 2. is more "structural", whereas 1. is more "nominal".
Once we've seen that, we're ready to accept that for any given domain, different event languages will yield have different characteristics of power and flexibility. My experience with Datomic tells me that, for a lot of domains, Datoms are a better language than a set of named Event Types.
To follow your example - if there's a "exceptional reputation change" event missing in the language - it has to be introduced which will force all the consequences on the downstream business to be considered. If this seems like a constraint - event sourcing might not be the proper solution.Or maybe we need a less strict definition of "Event Sourcing" than the one you have in mind? I think what matters is not what constitutes Event Sourcing in the strict sense - rather how do we get the benefits of Event Sourcing (see this part of the article).
If you find that designing events is hard work - you're doing the right thing! This means you probably are learning a lot about the domain.Maybe, and at the same time I'm wary of this sort of argument. We try to make flexible architectures precisely because we acknowledge the fact that our understanding of the domain will never be enough to anticipate every technical requirement.
On Wed, Nov 21, 2018 at 11:03 AM Val Waeselynck <val.v...@gmail.com> wrote:Imagine your domain consists of a dot moving on a square 2-dimensional grid. You could imagine 2 events systems (2 "languages") for describing each state transition:
- {MoveUp, MoveDown, MoveLeft, MoveRight, MoveUpLeft, MoveDownLeft, MoveUpRight, MoveDownRight, DontMove}
- {MoveBy(x, y)}
Both event systems describe all transitions in the domain, yet most people will probably agree that 2. is superior to 1. - 2. more expressive, and 1. yields a lot of over-specificity. 2. is more "structural", whereas 1. is more "nominal".I'd say that 1 is more expressive. It shows intent and result can be derived from that. Number 2 shows only the result.
Once we've seen that, we're ready to accept that for any given domain, different event languages will yield have different characteristics of power and flexibility. My experience with Datomic tells me that, for a lot of domains, Datoms are a better language than a set of named Event Types.To me Datomic feels like, as I understand correctly, an SQL database with the transaction log exposed. There are probably very good use-cases for this. But it feels very data-centric.As opposed to Event Sourcing in the original sense, which is more... how to call it.. 'action centered'?It shows the intent of the change in data. Correct me if I'm wrong, but with Datomic, I think it is hard to express e.g. this event:CreditWithdrawn {amount: 20,reason: 'Payback John'}
{:tx-data [#datom [johns-account :account/balance 1000 false 2132131231]
#datom [johns-account :account/balance 1020 true 2132131231]
#datom [alices-account :account/balance 500 false 2132131231]
#datom [alices-account :account/balance 480 true 2132131231]
#datom [transaction-entity :myapp/action :myapp.actions/credit-withdrawn]
#datom [transaction-entity :db/txInstant #inst "2018-08-22"]]}
Especially, if you want your current state to just be the balance.
To follow your example - if there's a "exceptional reputation change" event missing in the language - it has to be introduced which will force all the consequences on the downstream business to be considered. If this seems like a constraint - event sourcing might not be the proper solution.Or maybe we need a less strict definition of "Event Sourcing" than the one you have in mind? I think what matters is not what constitutes Event Sourcing in the strict sense - rather how do we get the benefits of Event Sourcing (see this part of the article).Benefits of Event Sourcing are tracking change, for which Datomic looks very promising. But also to track intent, or meta-info about change. I think that part is missing in Datomic.
If you find that designing events is hard work - you're doing the right thing! This means you probably are learning a lot about the domain.Maybe, and at the same time I'm wary of this sort of argument. We try to make flexible architectures precisely because we acknowledge the fact that our understanding of the domain will never be enough to anticipate every technical requirement.For this reason, I think it is best to record everything you know about the change in state. Maybe most of the info is currently not needed but in the future it could turn out to be very useful.E.g. in the CreditWithdrawn example, maybe you currently only need to know how much credit someone has. But in a far later time you might wonder what the most common reason for the withdraw was, which you can derive from reinterpreting the events.
--
You received this message because you are subscribed to a topic in the Google Groups "DDD/CQRS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dddcqrs/x-4jHq7nA5g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dddcqrs+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/dddcqrs.
For more options, visit https://groups.google.com/d/optout.
If I understand correctly this article, events are replaced by a stream of changes of a single entity attribute
called datoms which are bundled together by a transaction meaning that every datom has the same transaction id. So how in this case should we determine which event a particular transaction (ios set of datoms) is representing?
On the other hand the goal of an event-sourced and event-driven system is to store the events as they are, not by their change-set on other domain entities.