Events on DRUGs
Disclaimer
What is an Event?
In DDD meaning
Domain Event: a data structure representing one domain change
An event is something that has happened in the past
- It's a fact
- It's a struct
- It's a mutation
Issues: naming
I recommend using natural language and make small sentences, such as “Stock was depleted”, instead of newspaper-style shortcuts such as “Depleted stock”. In my experience, this greatly improves the communication and understanding.
- Past tense
	- ItemWasAdded
- ProductWasOrdered
- InvoiceEmailWasChanged
- ToggleWasSwitchedOff
 
- Noun(s) + verb
	- Mutated thing + was + action
 
- Use Domain Language
Issues: granularity
TL;DR
It's tricky
Small
- AddressWasChanged
- EmailWasChanged
- FirstNameWasChanged
Big
- ProfileWasChanged
- More flexibility
- Less "ifs" in event handlers but more "ifs" in command handlers
- Better language
- Possibly many events to handle after a single request
- Requires routing for handling
- Complex actions = heavy methods
- Fragile for struct changes and nulls
- Redundant data on small changes
Heuristics for grouping
- significance
- subscribers
- mutuality
Essential details
- every related aggregate id
- timestamp
- struct version number
- mutated data
Might help: http://verraes.net/2014/11/domain-events/
weak schema
vs
strict schema
Must read
Bonus thoughts
- You don't need DDD to start emitting events
- You don't need CQRS to start emitting events
- You don't need handlers to start emitting events
- You don't need to save emitted events

- audit log of changes
- force to think about domain
	- language
- transactions
- triggers
 
domain events vs integration events
GDPR
Last but not least

What we already know is not boring
Number of software developers double every five years
Questions?
Events on DRUGs
By Jan Dudulski
Events on DRUGs
- 114
 
   
   
  