121
2017-04-07T09:30 E V E N T B A S E D M O D E L L I N G P R O T O T Y P I N G &

Event based modelling and prototyping

Embed Size (px)

Citation preview

Page 1: Event based modelling and prototyping

2017-04-07T09:30

E V E N T B A S E D

M O D E L L I N G

P R O T O T Y P I N G

&

Page 2: Event based modelling and prototyping

Andrea Gian Maria Alessandro

Page 3: Event based modelling and prototyping
Page 4: Event based modelling and prototyping

Artigiani del software

Page 5: Event based modelling and prototyping
Page 6: Event based modelling and prototyping

FAIL FAST

Page 7: Event based modelling and prototyping
Page 8: Event based modelling and prototyping

Prenotazione attrezzature

Page 9: Event based modelling and prototyping
Page 10: Event based modelling and prototyping
Page 11: Event based modelling and prototyping
Page 12: Event based modelling and prototyping
Page 13: Event based modelling and prototyping
Page 14: Event based modelling and prototyping

“Nothing surprises me; I’m a scientist.”

Page 15: Event based modelling and prototyping

ResourceTypes ResourcesUsers Reservations

4 Tabelle

Page 16: Event based modelling and prototyping

Tabelle? Non è DDD!

Page 17: Event based modelling and prototyping

ResourceTypes ResourcesUsers Reservations

4 Tabelle

Page 18: Event based modelling and prototyping

ResourceType ResourceUser Reservation

4 Aggregati

Page 19: Event based modelling and prototyping
Page 20: Event based modelling and prototyping

ResourceType ResourceUser Reservation

4 Aggregati

Page 21: Event based modelling and prototyping

ResourceType

Resource

User

Reservation

Aggregati

Value Objects

+

Page 22: Event based modelling and prototyping
Page 23: Event based modelling and prototyping

“Non l’abbiamo evidenziato perché è

scontato che il software lo faccia”

Page 24: Event based modelling and prototyping

“Dobbiamo fare un sistema migliore del precedente, con più

funzionalità”

Page 25: Event based modelling and prototyping

Statistiche utente / risorsa / tipologia

L’auto è in officina

Il PC non è configurato

Alla fine di una riunione la sala deve essere pulita prima di essere nuovamente disponibile

Gli utenti prenotano le attrezzature disponibili……e il nostro ufficio decide a chi darle.

Un utente può annullare una prenotazione……ma noi dobbiamo confermare l’annullamento.

Alcune richieste hanno precedenza su altre

La berlina è riservata al C.D.A.

Storico delle prenotazioni

Notifiche ad ogni evento

Page 26: Event based modelling and prototyping

Aggiungiamo un flag

Page 27: Event based modelling and prototyping

Storicizziamo il dato

Page 28: Event based modelling and prototyping

Gestiamo l’eccezione

Page 29: Event based modelling and prototyping

Iniettiamo un servizio…

Page 30: Event based modelling and prototyping
Page 31: Event based modelling and prototyping

“FIRST, SOLVE THE PROBLEMTHEN WRITE THE CODE”

John Johnson

Page 32: Event based modelling and prototyping

is the most important part of the strategy.

ITERATION

It needs to be very, very fast and always based on learning.

Page 33: Event based modelling and prototyping

ALWAYS KEEP LEARNING

You stop doing useful things if you

don't learn.Satya Nadella

Page 34: Event based modelling and prototyping

Problem Model Code

Page 35: Event based modelling and prototyping

Problem

Intent Action Reaction

Page 36: Event based modelling and prototyping

EVENT EVENT EVENT EVENT

Timeline

INTENT

DECISION SUPPORT

REACTIONEVENT EVENT

NOTIFICATION

Problem Space

Page 37: Event based modelling and prototyping

EVENT EVENT EVENT EVENT

Stream

COMMAND

READ MODEL

PROCESSEVENT EVENT

SUBSCRIPTION

Solution Space

Page 38: Event based modelling and prototyping

EVENT EVENT EVENT EVENT

Stream

COMMAND

READ MODEL

PROCESSEVENT EVENT

SUBSCRIPTION

EVENT EVENT EVENT EVENT

Timeline

INTENT

DECISION SUPPORT

REACTIONEVENT EVENT

NOTIFICATION

Problem Space

Solution Space

Page 39: Event based modelling and prototyping

PROBLEM

Page 40: Event based modelling and prototyping
Page 41: Event based modelling and prototyping
Page 42: Event based modelling and prototyping

is a workshop format for

Event Storming

quickly exploring complex business domains

Page 43: Event based modelling and prototyping

Il tempo scorre in questa direzione

Page 44: Event based modelling and prototyping

Un pennarello a testa

Page 45: Event based modelling and prototyping

Start!

Page 46: Event based modelling and prototyping

Goal + KPI Goal + KPI Goal + KPI

Page 47: Event based modelling and prototyping

Event

Page 48: Event based modelling and prototyping

Rappresenta qualcosa di significativo accaduto nel

dominio.

Event

Page 49: Event based modelling and prototyping

RichiestaApprovata

Page 50: Event based modelling and prototyping

Attacchiamo i primi eventi disponendoli sull’asse temporale

RichiestaApprovata

RichiestaConfermata

RichiestaRespinta

Page 51: Event based modelling and prototyping

Command

Page 52: Event based modelling and prototyping

Indica l’intento dell’utente

Command

Page 53: Event based modelling and prototyping

ApprovaRichiesta

Page 54: Event based modelling and prototyping

Associamo ad ogni evento il comando relativo.

ApprovaRichiesta

Page 55: Event based modelling and prototyping
Page 56: Event based modelling and prototyping

Read Model

Page 57: Event based modelling and prototyping

Rappresenta il supporto decisionale per l’utente

Read Model

Page 58: Event based modelling and prototyping

Lista delle attrezzature disponibili

Page 59: Event based modelling and prototyping

Il readmodel aiuta ad identificare le informazioni necessarie all’utente per prendere decisioni

Lista delle attrezzature disponibili

Page 60: Event based modelling and prototyping

Ubiquitous language

Page 61: Event based modelling and prototyping

Definisce con precisione il significato di ogni termine

Ubiquitous language

Page 62: Event based modelling and prototyping

Attrezzatura Bene materiale

oggetto di prenotazione

Page 63: Event based modelling and prototyping

Attrezzatura Bene materiale oggetto di

prenotazione

ambiguitàconvergenza sul significato dei termini

Page 64: Event based modelling and prototyping

Problema smontato!

Page 65: Event based modelling and prototyping

is a workshop format for

Event Storming

quickly exploring complex business domains

non compila!!!

Page 66: Event based modelling and prototyping

MODEL

Page 67: Event based modelling and prototyping

DOMAIN DRIVEN DESIGN

Page 68: Event based modelling and prototyping

Un Domain Model non rappresenta la realtà, la sua rappresentazione è funzionale esclusivamente al caso d’uso.

https://www.theguardian.com/news/datablog/gallery/2013/jan/09/london-underground-alternative-tube-maps

Page 69: Event based modelling and prototyping
Page 70: Event based modelling and prototyping

ENTITYRisorsa_1

Registrata

Abilitata

Prenotata

Consegnata

Resa

Bloccata

Dismessa

Risorsa_2Registrata

Abilitata

Prenotata

Consegnata

Resa

Bloccata

Dismessa

Page 71: Event based modelling and prototyping

VALUE OBJECT{ “Descrizione” : “Notebook”, “Ram” : “16gb” }

{ “Descrizione” : “Notebook”, “Ram” : “16gb” }

{ “Descrizione” : “Tablet”, “Colore” : “Space Gray” }

{ “Descrizione” : “Tablet”, “Colore” : “Total Black” }

{ “Descrizione” : “Notebook”, “Ram” : “16gb”, “Matricola” : “MB1039” }

{ “Descrizione” : “Notebook”, “Ram” : “16gb”, “Matricola” : “MB1040” }

Page 72: Event based modelling and prototyping

AGGREGATE ROOTEntity

Entity

Entity

Entity

Entity

Rule

Rule

Rule

value object

value object

value object

value object

Page 73: Event based modelling and prototyping

FACTORY

Page 74: Event based modelling and prototyping

REPOSITORY

Page 75: Event based modelling and prototyping

Event Sourcing

Page 76: Event based modelling and prototyping

“Capture all changes to an application state as a sequence of events.”

Event Sourcing

http://martinfowler.com/eaaDev/EventSourcing.html

TimeRisorsa Censita

Risorsa resa

disponibile

Prenotazione Inserita

Prenotazione Approvata

Prenotazione Inserita

Prenotazione Confermata

Prenotazione Non

Approvata

Risorsa Dismessa

Page 77: Event based modelling and prototyping

Risorsa Censita

Risorsa resa

disponibile

Prenotazione Inserita

Prenotazione Approvata

Prenotazione Inserita

Prenotazione Confermata

Prenotazione Non

Approvata

Risorsa Dismessa

Risorsa_1 Prenotazione_1 Prenotazione_2

Page 78: Event based modelling and prototyping

Title : ”Budget 2014 - IT”, LastModified : “2013-09-15”, Tags : [],Author: “Board of Directors”,PublishedBy: null, File: “Budget.xlsx”

Who: “Mr. Smith”, Why: “DocumentCreated”,When: “2013-09-15 18:35”, What:{ Title : ”Budget 2014 - IT”, Author: “Board of Directors”, File: “Budget.xlsx” }

Who: “Mary J.”, Why: “RevisionAdded”,When: “2013-09-16 09:40”, What: { File: “Budget with Costs.xlsx” }

Who: “Mary J.”, Why: “DocumentTagged”,When: “2013-09-16 09:40”, What: { Tags : [“Draft”, “Accounting”] }

Who: “Luther Blissett”, Why: “RevisionAdded”,When: “2013-12-06 21:35”, What: { File: “Budget with Costs & Sales Forecast.xlsx”}

Who: “Luther Blissett”, Why: “DocumentTagged”,When: “2013-12-06 21:35”, What: { Tags : [“Budget”,”Sales”,“Accounting”] }

Who: “Jane Doe”, Why: “DocumentPublished”,When: “2014-01-05 23:17”, What : { Title : “Budget 2014” Tags : [“Budget”,”Sales”,“Accounting”] }

TIME

Title : ”Budget 2014”, LastModified : “2014-01-05”, Tags : [“Budget”, “Sales”, “Accounting”],Author: “Board of Directors”,PublishedBy: “Jane Doe”, File: “Budget with Costs & Sales Forecast.xlsx”

Title : ”Budget 2014 - IT”, LastModified : “2013-09-16”, Tags : [“Draft”, “Accounting”],Author: “Board of Directors”,PublishedBy: null, File: “Budget with Costs.xlsx”

Title : ”Budget 2014 - IT”, LastModified : “2013-12-06”, Tags : [“Budget”,”Sales”,“Accounting”],Author: “Board of Directors”,PublishedBy: null, File: “Budget with Costs & Sales Forecast.xlsx”

Information Loss

Page 79: Event based modelling and prototyping

15 Settembre

2013

16 Settembre

2013

12 Dicembre

2013

5 Gennaio

2014

6 Maggio

2014

Page 80: Event based modelling and prototyping

CQRS

Page 81: Event based modelling and prototyping

CQRS“At its heart is a simple notion that you can use a

different model to update information than the model you use to read information”

http://martinfowler.com/bliki/CQRS.html

Page 82: Event based modelling and prototyping

Business Logic

Decision support system

Page 83: Event based modelling and prototyping
Page 84: Event based modelling and prototyping

Business Logic

Decision support system

Page 85: Event based modelling and prototyping

Business Logic

Decision support system

Page 86: Event based modelling and prototyping

Query

Command

Page 87: Event based modelling and prototyping

join the dots…

Page 88: Event based modelling and prototyping

Query

Command

Read Model

Domain Model

Page 89: Event based modelling and prototyping

Command

Read Model

Query

Domain Model

Page 90: Event based modelling and prototyping

Read Model

Domain Model

Page 91: Event based modelling and prototyping

Read Model

Application StateAggregate

Command

Event Event

Event

Page 92: Event based modelling and prototyping

Read Model

Application StateAggregate

Command Event Event

Event

Page 93: Event based modelling and prototyping

Read Model

EventstreamAggregate

Projection

Command

Event Event

EventEvent

Page 94: Event based modelling and prototyping

Read Model

EventstreamAggregate

Projection

Command

Event Event

EventEvent

Query

DDD+CQRS+ES

Page 95: Event based modelling and prototyping

EVENT EVENT EVENT EVENT EVENT

Timeline

COMMAND

READ MODEL

Action Mutation

PROCESS

Reaction

EVENT EVENT EVENT

Write Read

SUBSCRIPTION

Page 96: Event based modelling and prototyping

MODELLATHON

Page 97: Event based modelling and prototyping

Defrag

Page 98: Event based modelling and prototyping

Aggreghiamo i post-it

Defrag

Page 99: Event based modelling and prototyping
Page 100: Event based modelling and prototyping

Aggregato Aggregato

Bounded Context

Aggregato

Bounded Context

Page 101: Event based modelling and prototyping

Invarianti

Page 102: Event based modelling and prototyping

Sono le regole che non possiamo violare

Invarianti

Page 103: Event based modelling and prototyping

Non sono ammesse prenotazioni sovrapposte per singola attrezzatura.

Page 104: Event based modelling and prototyping

Aggregato Aggregato

Bounded Context

Aggregato

Bounded Context

Non sono ammesse prenotazioni sovrapposte per singola attrezzatura.

Page 105: Event based modelling and prototyping

Transizioni

Page 106: Event based modelling and prototyping

Esploriamo le relazioni tra comandi ed eventi

Transizioni

Page 107: Event based modelling and prototyping

Aggregato Aggregato

Bounded Context

Aggregato

Bounded Context

Page 108: Event based modelling and prototyping

Aggregato

Page 109: Event based modelling and prototyping
Page 110: Event based modelling and prototyping

if()

Page 111: Event based modelling and prototyping

if()

Page 112: Event based modelling and prototyping

Processmanager

Page 113: Event based modelling and prototyping

Rappresenta un processo di business complesso

Processmanager

Page 114: Event based modelling and prototyping

Assegnazione attrezzatura

Page 115: Event based modelling and prototyping

Assegnazione attrezzatura

Page 116: Event based modelling and prototyping

Command Query Responsibility Segregation

Command

Process Manager

Event

Event

Aggregate

Projections

Read Model

Read Model

Page 117: Event based modelling and prototyping

Assegnazione attrezzatura

Page 118: Event based modelling and prototyping

CODE

Page 119: Event based modelling and prototyping
Page 120: Event based modelling and prototyping

Assegnazione attrezzatura

Lista delle attrezzature disponibili

ApprovaRichiesta

RichiestaApprovata

Non sono ammesse prenotazioni sovrapposte per singola attrezzatura.

Page 121: Event based modelling and prototyping

AssegnazioneAttrezzature

(process)

AttrezzatureDisponibili

(model)

ApprovaRichiesta

(command)

RichiestaApprovata

(event)

VietaPrenotazioniSovrapposte

(business rule)