event based modelling and prototyping

Post on 14-Apr-2017

68 Views

Category:

Software

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

&

Andrea Gian Maria Alessandro

Artigiani del software

FAIL FAST

Prenotazione attrezzature

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

ResourceTypes ResourcesUsers Reservations

4 Tabelle

Tabelle? Non è DDD!

ResourceTypes ResourcesUsers Reservations

4 Tabelle

ResourceType ResourceUser Reservation

4 Aggregati

ResourceType ResourceUser Reservation

4 Aggregati

ResourceType

Resource

User

Reservation

Aggregati

Value Objects

+

“Non l’abbiamo evidenziato perché è

scontato che il software lo faccia”

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

funzionalità”

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

Aggiungiamo un flag

Storicizziamo il dato

Gestiamo l’eccezione

Iniettiamo un servizio…

“FIRST, SOLVE THE PROBLEMTHEN WRITE THE CODE”

John Johnson

is the most important part of the strategy.

ITERATION

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

ALWAYS KEEP LEARNING

You stop doing useful things if you

don't learn.Satya Nadella

Problem Model Code

Problem

Intent Action Reaction

EVENT EVENT EVENT EVENT

Timeline

INTENT

DECISION SUPPORT

REACTIONEVENT EVENT

NOTIFICATION

Problem Space

EVENT EVENT EVENT EVENT

Stream

COMMAND

READ MODEL

PROCESSEVENT EVENT

SUBSCRIPTION

Solution Space

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

PROBLEM

is a workshop format for

Event Storming

quickly exploring complex business domains

Il tempo scorre in questa direzione

Un pennarello a testa

Start!

Goal + KPI Goal + KPI Goal + KPI

Event

Rappresenta qualcosa di significativo accaduto nel

dominio.

Event

RichiestaApprovata

Attacchiamo i primi eventi disponendoli sull’asse temporale

RichiestaApprovata

RichiestaConfermata

RichiestaRespinta

Command

Indica l’intento dell’utente

Command

ApprovaRichiesta

Associamo ad ogni evento il comando relativo.

ApprovaRichiesta

Read Model

Rappresenta il supporto decisionale per l’utente

Read Model

Lista delle attrezzature disponibili

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

Lista delle attrezzature disponibili

Ubiquitous language

Definisce con precisione il significato di ogni termine

Ubiquitous language

Attrezzatura Bene materiale

oggetto di prenotazione

Attrezzatura Bene materiale oggetto di

prenotazione

ambiguitàconvergenza sul significato dei termini

Problema smontato!

is a workshop format for

Event Storming

quickly exploring complex business domains

non compila!!!

MODEL

DOMAIN DRIVEN DESIGN

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

ENTITYRisorsa_1

Registrata

Abilitata

Prenotata

Consegnata

Resa

Bloccata

Dismessa

Risorsa_2Registrata

Abilitata

Prenotata

Consegnata

Resa

Bloccata

Dismessa

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” }

AGGREGATE ROOTEntity

Entity

Entity

Entity

Entity

Rule

Rule

Rule

value object

value object

value object

value object

FACTORY

REPOSITORY

Event Sourcing

“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

Risorsa Censita

Risorsa resa

disponibile

Prenotazione Inserita

Prenotazione Approvata

Prenotazione Inserita

Prenotazione Confermata

Prenotazione Non

Approvata

Risorsa Dismessa

Risorsa_1 Prenotazione_1 Prenotazione_2

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

15 Settembre

2013

16 Settembre

2013

12 Dicembre

2013

5 Gennaio

2014

6 Maggio

2014

CQRS

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

Business Logic

Decision support system

Business Logic

Decision support system

Business Logic

Decision support system

Query

Command

join the dots…

Query

Command

Read Model

Domain Model

Command

Read Model

Query

Domain Model

Read Model

Domain Model

Read Model

Application StateAggregate

Command

Event Event

Event

Read Model

Application StateAggregate

Command Event Event

Event

Read Model

EventstreamAggregate

Projection

Command

Event Event

EventEvent

Read Model

EventstreamAggregate

Projection

Command

Event Event

EventEvent

Query

DDD+CQRS+ES

EVENT EVENT EVENT EVENT EVENT

Timeline

COMMAND

READ MODEL

Action Mutation

PROCESS

Reaction

EVENT EVENT EVENT

Write Read

SUBSCRIPTION

MODELLATHON

Defrag

Aggreghiamo i post-it

Defrag

Aggregato Aggregato

Bounded Context

Aggregato

Bounded Context

Invarianti

Sono le regole che non possiamo violare

Invarianti

Non sono ammesse prenotazioni sovrapposte per singola attrezzatura.

Aggregato Aggregato

Bounded Context

Aggregato

Bounded Context

Non sono ammesse prenotazioni sovrapposte per singola attrezzatura.

Transizioni

Esploriamo le relazioni tra comandi ed eventi

Transizioni

Aggregato Aggregato

Bounded Context

Aggregato

Bounded Context

Aggregato

if()

if()

Processmanager

Rappresenta un processo di business complesso

Processmanager

Assegnazione attrezzatura

Assegnazione attrezzatura

Command Query Responsibility Segregation

Command

Process Manager

Event

Event

Aggregate

Projections

Read Model

Read Model

Assegnazione attrezzatura

CODE

Assegnazione attrezzatura

Lista delle attrezzature disponibili

ApprovaRichiesta

RichiestaApprovata

Non sono ammesse prenotazioni sovrapposte per singola attrezzatura.

AssegnazioneAttrezzature

(process)

AttrezzatureDisponibili

(model)

ApprovaRichiesta

(command)

RichiestaApprovata

(event)

VietaPrenotazioniSovrapposte

(business rule)

top related