why domain-driven design and reactive programming?

60
Why Domain-Driven Design and Reactive Programming? Vaughn Vernon – Distinguished Author and Consultant Wes Williams – Pivotal Software Designer & Architect

Upload: pivotal

Post on 15-Apr-2017

972 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Why Domain-Driven Design and Reactive Programming?

Why Domain-Driven Design and Reactive Programming?

Vaughn Vernon – Distinguished Author and ConsultantWes Williams – Pivotal Software Designer & Architect

Page 2: Why Domain-Driven Design and Reactive Programming?

My Best Selling Books

@VaughnVernon

Page 3: Why Domain-Driven Design and Reactive Programming?

What Causes Software Projects to Lack Well-Designed Domains?

Page 4: Why Domain-Driven Design and Reactive Programming?

Data-Only Focus When You Should Aim Higher to Capitalize on Your Unique Business Drivers

Page 5: Why Domain-Driven Design and Reactive Programming?

Business Concepts are Seen Only as Data-Centric Anemic Entities

Page 6: Why Domain-Driven Design and Reactive Programming?

Here’s How it Happens

Page 7: Why Domain-Driven Design and Reactive Programming?

Oh Yeah, and …

Page 8: Why Domain-Driven Design and Reactive Programming?

Well, There are Also …

Page 9: Why Domain-Driven Design and Reactive Programming?

Don’t Forget …

Page 10: Why Domain-Driven Design and Reactive Programming?

Wouldn’t That Be …

Page 11: Why Domain-Driven Design and Reactive Programming?

Don’t Limit

Page 12: Why Domain-Driven Design and Reactive Programming?

It’s Getting Muddy

Page 13: Why Domain-Driven Design and Reactive Programming?

Cavaet: Big Ball of Mud

Your entities grow in number until no one understands the tangled web.

Page 14: Why Domain-Driven Design and Reactive Programming?

Team is Blinded by Data and Lack of Core Business Knowledge and Collaboration

Page 15: Why Domain-Driven Design and Reactive Programming?

What is a Good Domain Model and How Does it Help with Reducing Complexity?

Page 16: Why Domain-Driven Design and Reactive Programming?

Invest in Business Knowledge

Developers Domain Experts

Page 17: Why Domain-Driven Design and Reactive Programming?

Business Value: Unify Mental Models Through a Team-Developed Domain Language

??????

Page 18: Why Domain-Driven Design and Reactive Programming?

Segregate the Language Into a Well-Defined Software Model

Page 19: Why Domain-Driven Design and Reactive Programming?

Strategic Design Tool: Bounded Context

Strategic Design Tool: Bounded Context

Page 20: Why Domain-Driven Design and Reactive Programming?

Inside the Boundary the Concepts Have Well Defined Context

Page 21: Why Domain-Driven Design and Reactive Programming?

Outside The Boundary Other Concepts Will Not Adhere to The Context of our Model

Page 22: Why Domain-Driven Design and Reactive Programming?

Using These Principles We Can Challenge The Tangle and Identify Our Core Language

Page 23: Why Domain-Driven Design and Reactive Programming?
Page 24: Why Domain-Driven Design and Reactive Programming?
Page 25: Why Domain-Driven Design and Reactive Programming?
Page 26: Why Domain-Driven Design and Reactive Programming?
Page 27: Why Domain-Driven Design and Reactive Programming?
Page 28: Why Domain-Driven Design and Reactive Programming?
Page 29: Why Domain-Driven Design and Reactive Programming?
Page 30: Why Domain-Driven Design and Reactive Programming?

Actual Core

Page 31: Why Domain-Driven Design and Reactive Programming?

Multiple Bounded Contexts

Page 32: Why Domain-Driven Design and Reactive Programming?

What is Reactive Software and How Does it Help Developers Solve

Complex Application and Integration Problems?

Page 33: Why Domain-Driven Design and Reactive Programming?

Must Integrate Multiple Bounded Contexts

Page 34: Why Domain-Driven Design and Reactive Programming?

Inside Bounded Contexts Are Aggregate Components

Page 35: Why Domain-Driven Design and Reactive Programming?

Aggregates Produce Facts: Domain Events

Page 36: Why Domain-Driven Design and Reactive Programming?

In App: Cross-Aggregates are Reactive

new

Page 37: Why Domain-Driven Design and Reactive Programming?

One Transaction Saves Aggregate and Event

Other Bounded Contexts react to Domain Events

Page 38: Why Domain-Driven Design and Reactive Programming?

How Can You Use These Techniques To Reduce Time-to-Market and Improve Quality as You Build

Software That is More Flexible, More Scalable, and More Tightly Aligned to

Business Goals?

Page 39: Why Domain-Driven Design and Reactive Programming?

Time-to-Market is Reduced Through Modeling with Business Knowledge

Page 40: Why Domain-Driven Design and Reactive Programming?

Software Quality is Enhanced and Business Goals Achieved Through the Bounded Context and Ubiquitous Language

Page 41: Why Domain-Driven Design and Reactive Programming?

Software is More Scalable Through Smaller Focused Bounded Contexts

Page 42: Why Domain-Driven Design and Reactive Programming?

How Can In-Memory Data Grids Like Open Source Apache Geode and Pivotal GemFire (Based on Apache Geode) Fit With These

Modern Concepts?

Page 43: Why Domain-Driven Design and Reactive Programming?

Pivotal Software

Wes WilliamsPivotal Data Engineering

[email protected]

Largest startup in history of Silicon Valley

Helping enterprises scale withProcess + OS Software + Data Engineering

Page 44: Why Domain-Driven Design and Reactive Programming?

Reactor & DDD - Demo

High-speedPrice Feed

Pivotal GemFire

Execution Management System

Algorithmic Trading System

DDD Style

https://github.com/reactor/reactor-kafka

Stream – convert quotes to price bars

Wall Street Automated Trading Strategy

https://github.com/VaughnVernon/IDDD_NYSE

Page 45: Why Domain-Driven Design and Reactive Programming?

Reactive Kafka – Why?

High-speedstreaming transactions

Pivotal GemFire

High-speedstreaming transactions

Pivotal GemFire

20,000 txns/ sec on a 4-core 2.8 GHz MAC

1,000,000 txn / sec on a 4-core 2.8 GHz MAC

Asynch put micro-batches

Auto-replay batches in case of commit failure

Page 46: Why Domain-Driven Design and Reactive Programming?

GemFire – Why?

Region

get(key)

Aggregate

In-memory object grid

Business logic and data are co-located

DDD + GemFire =A natural complement!

Data must be serialized first from across network.

Page 47: Why Domain-Driven Design and Reactive Programming?

GemFire – Eventing ArchitectureApplicatio

nApplicatio

n

DB or other Data Store

Orders

Update!Continuous QuerySelect * from /EventStore where type = “Buy Order”Cache

Write

Algorithmic Orders

EventStore

Listening for new orders

Built-in Event-Driven Architecture

Page 48: Why Domain-Driven Design and Reactive Programming?

GemFire – Fast Calculations

High-speedcalculations

Algorithmic Trading System

Pivotal GemFire

Flight Scheduler Target Marketing

<Your company’s analytic here>

Page 49: Why Domain-Driven Design and Reactive Programming?

Demo Features

1. Windowing – Convert a stream of quotes into a 1-second price bar.

2. Analytics – Calculate the Volume-Weighted Average Price on each bar

3. Submit Buy Order for 25,000 shares

4. Algorithmically execute the order in 1,000-share “slices” until filledUsing DDD & Reactor technology with an In-memory Data Grid

Page 50: Why Domain-Driven Design and Reactive Programming?

Demo – Convert Prices to …

High-speedPrice Feed

Pivotal GemFire

Price feed - emits price quotes in a pseudo-random wave pattern with a 5% range

5-second price bars for AAPL

Creating price bars in a 1-second window

open

highclose

low

Page 51: Why Domain-Driven Design and Reactive Programming?

Demo - Analytics

Volume-Weighted Average Price

Execute trade when VWAP < target price

open

close

Calculate VWAP Evaluate Trade

Σ (price * volume)________________________________________________________

Σ (volume)VWAP =

Page 52: Why Domain-Driven Design and Reactive Programming?

GemFire – Eventing ArchitectureApplicatio

nApplicatio

n

Orders

Update!

Continuous QuerySelect * from /EventStore where type = “Buy Order”

Algo Orders

EventStore

Listening for new orders

Submit a “Buy” request for 25,000 shares

Submit Order to trade algorithmically

Will submit orders 1,000 shares at a time until the entire order is filled

Page 53: Why Domain-Driven Design and Reactive Programming?

Demo

Page 54: Why Domain-Driven Design and Reactive Programming?

Demo Summary

1. DDD and Reactor – Powerful best practices and practical for the enterprise

2. GemFire – A natural complement to DDD due to being an object IMDG, built-in eventing. Can use with Reactor streaming for Fast Analytics.

3. Reactor Kafka - Enables extremely high throughput

Thanks to Vaughn Vernon for modifying the trading system to DDD style

Page 55: Why Domain-Driven Design and Reactive Programming?

Next Steps

Page 56: Why Domain-Driven Design and Reactive Programming?

My Best Selling Books

@VaughnVernon

Page 57: Why Domain-Driven Design and Reactive Programming?

http://idddworkshop.com

Page 58: Why Domain-Driven Design and Reactive Programming?

Pivotal Resources• Pivotal GemFire

• Features, Benefits, Use Cases:https://pivotal.io/big-data/pivotal-gemfire

• Free Intro Online Course: https://pivotal.io/academy/course/introduction-to-gemfire

• Today’s Demo:https://github.com/VaughnVernon/IDDD_NYSEhttps://github.com/reactor/reactor-kafka

• Apache Geode• Site: http://geode.apache.org/• Geode Summit: https://2016.event.geodesummit.com/schedule• Upcoming Community Discussion with Vaughn Vernon: Weds, Sept 21, 9AM

PacificMeeting URL: https://pivotal.zoom.us/j/540483502

Page 59: Why Domain-Driven Design and Reactive Programming?
Page 60: Why Domain-Driven Design and Reactive Programming?