• Save
State or intent
Upcoming SlideShare
Loading in...5
×
 

State or intent

on

  • 730 views

Slides for a lighting talk about event sourcing I held 14th of June in 2013 at NDC Oslo.

Slides for a lighting talk about event sourcing I held 14th of June in 2013 at NDC Oslo.

Statistics

Views

Total Views
730
Views on SlideShare
682
Embed Views
48

Actions

Likes
1
Downloads
0
Comments
0

4 Embeds 48

https://twitter.com 20
http://ec2-54-243-189-159.compute-1.amazonaws.com 13
http://www.linkedin.com 9
http://eventifier.co 6

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Present thetopic Deployment
  • Keep it short
  • I’ve written down ”Anemic domain model” since the domain objects we have are loaded by mapping, and we are not setting the properties of our object based on domain actions/events.
  • I don’t know, it’s still just the data no extra information. Maybe some mapping, but the tools we have today for relational databases often solve that.We are not solving the real problem we are only subotimizing what we do. It’s like putting a bandaid on a broken leg.
  • And how can we do that? Use event sourcing.What will we gaing? Click.
  • What does this mean? This means you have to have your business logic before saving the event.
  • Instead of focusing on this data need to be stored and that should set this flag in this table you shift focus to what the intention of the action is. If the action succeed you store the intention (or event).
  • Testing is simple and explicit. The setup is clear, the action is clear and the intention is clear.
  • You can load them from a set of events.The events is part of the domain.

State or intent State or intent Presentation Transcript

  • STATE OR INTENT?An Introduction to Event SourcingOslo/NDCTomas Jansson14/06/2013
  • THIS IS METomas JanssonManager & Group Lead .NETBEKK Oslo@TomasJanssontomas.jansson@bekk.nogithub.com/mastojblog.tomasjansson.com
  • WHY USE NOSQL IF WE ARE STORING THE SAME THING?StateTablesORMAnemic domain modelStateDocumentMappingAnemic domain modelRDBMSNoSQL(Document store)
  • WHAT DO WE REALLY GAIN WITH A DOCUMENT STORE??
  • STORE THE INTENT INSTEAD OF THE STATEEventSourcingUnderstandthebusinessTestingNoimpedancemismatchIntegrationError fixingAdditionalvalue fromhistory
  • WHAT IS AN EVENT?An event is something that has happened in the pastExamples:CustomerMovedTableReservedOrderPlacedCompare to actions:MoveCustomerReserveTablePlaceOrder
  • UNDERSTAND THE BUSINESSWhat data is storedWhat was theintention (the event)Focus
  • TESTING 1: SOMEONE CORRECTS THE ADDRESS OF A CUSTOMER[TestFeature]public class CustomerTests : BaseTestSetup{[Test]public void When_The_Changing_The_Address_The_Address_Should_Change(){// GivenAddEvent(new CustomerCreated(1, "Tomas"));AddEvent(new AddressAdded(1, new Address("Street 1", "Oslol", "4040", "Norway")));var customer = _domainRepository.Get<Customer>(1);// Whencustomer.CorrectAddress(new Address("Street 1", "Oslo", "4040", "Norway"));var events = _domainRepository.Commit();// ThenAssert.AreEqual(1, events.Count());Assert.Contains(new AddressChanged("Street 1", "Oslo", "4040", "Norway"), events);}}
  • TESTING 2: A CUSTOMER MOVES[TestFeature]public class CustomerTests : BaseTestSetup{[Test]public void When_The_Customer_Moves_The_Address_Should_Change_And_Notify(){// GivenAddEvent(new CustomerCreated(1, "Tomas"));AddEvent(new AddressAdded(1, new Address("Street 1", "Oslo", "4040", "Norway")));var customer = _domainRepository.Get<Customer>(1);// Whencustomer.Move(new Address("New Street 9", "Oslo", "6666", "Norway"));var events = _domainRepository.Commit();// ThenAssert.AreEqual(2, events.Count());Assert.Contains(new CustomerMoved(1), events);Assert.Contains(new AddressChanged("Street 1", "Oslo", "4040", "Norway"), events);}}Testing what we really expect to happen, and we also tests theabsence of side effects!
  • NO IMPEDANCE MISMATCHpublic class Customer{private Address _address;public Customer(IEnumerable<IEvent> events){ ... }private void Handle(AddressChanged @event){_address = @event.Address;}public void Move(Address address){ ... }public void ChangeAddress(Address address){ ... }...}Build instance from eventsAddressChanged (an event)is part of the domain
  • THE LAST THREEEasier to make integrationasync and explicitParties that are intrested canjust tail the event sourceFocus is on behavior  fixingthe root cause instead ofchanging the dataComplete audit logJust replay the eventsIntegration Error fixingAdditional valuefrom history
  • THE NEGATIVE SIDE OF EVENT SOURCINGDefining events is hard!No tooling availableLack of information regarding Event SourcingProjection of the events might be considered complex
  • RESOURCESRinat Abduling about why event sourcing: http://bliki.abdullin.com/event-sourcing/whyEvents as a storage mechanism: http://cqrs.wordpress.com/documents/events-as-storage-mechanism/My post about the subject: http://tinyurl.com/StateOrIntent
  • Thank you!@TomasJansson