Polyglot heaven

Post on 07-Jul-2015

645 views 2 download

Tags:

description

A presentation about data and how to build polyglot applications. The key component, as I see it, to build polyglot data applications is to use an event store as the master data storage and then use other types of databases as views of that data. The presentation also touches on Command Query Responsibility Segragation, CQRS, and event sourcing.

Transcript of Polyglot heaven

POLYGLOT HEAVEN

How to Build an Async, Reactive Application in 2014

NDC London

Tomas Jansson

04/12/2014

POLYGLOT HEAVEN

How to Build an Async, Reactive Application in 2014

NDC London

Tomas Jansson

04/12/2014

And this should probably be 2015

This here, a title to get accept

THIS IS ME

Tomas Jansson

Manager & Practice Lead .NETBEKK Oslo

@TomasJanssontomas.jansson@bekk.nogithub.com/mastojblog.tomasjansson.com

AGENDA

WHY ASYNC AND REACTIVE?

LET’S TALK DATA

WHY POLYGLOT?

WHAT CAN WE DO?

DEMO

SUMMARY

WHY ASYNC AND REACTIVE? - ASYNC

Async doesn’t mean unreliable

Async gives you responsiveness

Data will be consistent

WHY ASYNC AND REACTIVE? - REACTIVE

Message based modular

React on changeEventual

consistent

LET’S TALK DATA

Let’s talk Data

LET’S TALK DATA

Are all data the same?

LET’S TALK DATA

What different kinds of data do we have?

LET’S TALK DATA

Changes, state, relations, cache...

”if all you have is a hammer, everything looks like a nail”

Why polyglot?

WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS

Documents

WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS

DocumentsDocument database

WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS

DocumentsDocument database

Changes

WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS

DocumentsDocument database

Changes Event store

WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS

DocumentsDocument database

Changes Event store

Relations

WHY POLYGLOT? – CHOOSE THE RIGHT TOOLS

DocumentsDocument database

RelationsGraph

database

Changes Event store

What can we do?

Change!

3-LAYERED ARCHITECTURE – WHY OH WHY?

3-LAYERED ARCHITECTURE – WHY OH WHY?

You are mixing your domain

with your query model!

What do you think about ”Divide and Conquer?”

COMMAND QUERY RESPONSIBILITY SEGREGATION - CQRS

CQRS is ”Divide and Conquer” applied on a

architecutral level

CQRS WITH EVENT SOURCING - OVERVIEW

ApplicationCommand Events

Events Projection View

CQRS WITH EVENT SOURCING - OVERVIEW

Application: f(x, ys) ys’, x: Command, ys: list of Events

Projection: f(y, ys) z, y: Event, ys: list of Events, z: View

CQRS WITH EVENT SOURCING - OVERVIEW

Application: f(x, ys) ys’, x: Command, ys: list of Events

Projection: f(y, ys) z, y: Event, ys: list of Events, z: View

Your application is a pure function!

How you implement it is secondary, the events are what

matters!

CQRS WITH EVENT SOURCING - TESTS

[Test]public void PlaceOrder_Should_CreateAnOrder() {

var productId = Guid.NewGuid();var customerId = Guid.NewGuid();var orderId = Guid.NewGuid();var orderItems =

Contracts.Helpers.ToFSharpList(new[] {new OrderItem(productId, 20)});

Given(new ProductCreated(productId, "a name", 20),new CustomerCreated(customerId, "John Doe"));

When(new PlaceOrder(orderId, customerId, orderItems));Then(new OrderPlaced(orderId, customerId, orderItems));

}

Pure functions are easy to test

WHAT WILL I SHOW TODAY?

ApplicationCommand Events

Events Projection View

WHAT WILL I SHOW TODAY?

ApplicationCommand Events

Events Projection View

HTTP

THE KEY COMPONENT

This is where the ”truth” is

stored

Demo!

View databases

Web

Application View

CreateCustomer

CreateProduct

PlaceOrder

GetRecommendations

GetCustomer

GetProduct

SUMMARY

Why async and reactive?

• Responsive

• Scalable

• Modular

SUMMARY

Why async and reactive?

• Responsive

• Scalable

• Modular

Why polyglot?

• Not all data is the same

• Not everything is a nail

SUMMARY

Why async and reactive?

• Responsive

• Scalable

• Modular

Why polyglot?

• Not all data is the same

• Not everything is a nail

Event sourcing and CQRS

• CQRS is divide and conquer on an architecture level

• Your application should be a function

• You don’t have to write in a functional language to write functional code (but it might make it easier)

SUMMARY

Why async and reactive?

• Responsive

• Scalable

• Modular

Why polyglot?

• Not all data is the same

• Not everything is a nail

Event sourcing and CQRS

• CQRS is divide and conquer on an architecture level

• Your application should be a function

• You don’t have to write in a functional language to write functional code (but it might make it easier)

http://www.slideshare.net/mastoj/polyglot-heaven

https://github.com/mastoj/PolyglotHeaven

http://open.bekk.no/polyglot-heaven-a-response-to-the-bekk-radar

Questions?

Thank you!

@TomasJansson