beyond ddd: uno sguardo a cqrs and event sourcing

18
Beyond DDD: uno sguardo a CQRS and event sourcing

Upload: alessandro-melchiori

Post on 11-May-2015

499 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Beyond DDD: uno sguardo a CQRS and event sourcing

Beyond DDD: uno sguardo a CQRS and event sourcing

Page 2: Beyond DDD: uno sguardo a CQRS and event sourcing

about me

{

"firstName": "Alessandro",

"lastName": "Melchiori",

"role": "software architect @ codiceplastico",

"contacts": [

{ "type": "email", "value": [email protected] },

{ "type": "twitter", "value": "@amelchiori" },

{ "type": "blog", "value": http://blog.codiceplastico.com/melkio }

]

}

Page 3: Beyond DDD: uno sguardo a CQRS and event sourcing

Il contesto• Applicazione finanziaria (non “always online”)

• Circa 70 utenti

• 250.000+ aziende

• 750.000+ bilanci

• 70.000.000+ voci di bilancio

• 16.000+ call/mese

• “Pluggato” a servizi di terze parti

• Picchi di lavoro “temporali” (…la nuvola può darci una mano)

Page 4: Beyond DDD: uno sguardo a CQRS and event sourcing

Agenda

• Com’era

• Com’è

• Come sarà

Page 5: Beyond DDD: uno sguardo a CQRS and event sourcing

Come era…Pr

esen

tatio

n La

yer

Serv

ice/

Appl

icati

on L

ayer

Dom

ain

Mod

el

Storage

Page 6: Beyond DDD: uno sguardo a CQRS and event sourcing

Come era…

Page 7: Beyond DDD: uno sguardo a CQRS and event sourcing

Come era…

Page 8: Beyond DDD: uno sguardo a CQRS and event sourcing

Come era…

Page 9: Beyond DDD: uno sguardo a CQRS and event sourcing

I problemi…

• Logica (mal) sparpagliata

• Contesti non definiti

• Modello “fragile” e poco propenso alle evoluzioni

• Un unico modello per la lettura e per la scrittura

• Prestazioni

• UI “generazionalista”

Page 10: Beyond DDD: uno sguardo a CQRS and event sourcing

DDD: brevi cenni

• Use AGGREGATES as unit of consistency across your domain model

• Protect your model with clearly defined BOUNDED CONTEXT

(Eric Evans)

BC 01 BC 02 BC 03

Page 11: Beyond DDD: uno sguardo a CQRS and event sourcing

DDD: brevi cenni

• It’s really become clear to me in the last couple of years that we need a new building block and that is the Domain Events

(Eric Evans)

BC 01 BC 02 BC 03

Page 12: Beyond DDD: uno sguardo a CQRS and event sourcing

CQRS / ES: brevi cenni

• Every method should either be a command that performs an action, or a query that returns data to the caller, but NOT BOTH

(Bertrand Meyer)

Page 13: Beyond DDD: uno sguardo a CQRS and event sourcing

CQRS / ES: brevi cenni

• A single model cannot be appropriate for reporting, searching and transactional behavior

• State transition are an important part of our problem space and should be modeled within our domain

(Greg Young, 2008)

Page 14: Beyond DDD: uno sguardo a CQRS and event sourcing

L’evoluzione

Page 15: Beyond DDD: uno sguardo a CQRS and event sourcing

Come è…Pr

esen

tatio

n La

yer

Serv

ice

Laye

r

Dom

ain

Mod

el

Write storage

Read storage

Page 16: Beyond DDD: uno sguardo a CQRS and event sourcing

Come sarà…

AZURE ?Service Bus

Blob Storage

Worker / Web Role

MongoDb (PaaS or SaaS)

ACS

Page 17: Beyond DDD: uno sguardo a CQRS and event sourcing

Quando DDD/CQRS/ES fanno per me?

Chiedilo al «tuo» UBIQUITOUS LANGUAGE

(Alessandro Melchiori)

Page 18: Beyond DDD: uno sguardo a CQRS and event sourcing

Quando DDD/CQRS/ES fanno per me?

Tackling Complexity in the Heart of Software