Slide 1

Slide 1 text

ConFoo Montreal Bradley Holt, Developer Advocate Thursday, March 9, 2017 Domain-Driven Data @BradleyHolt

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

@BradleyHolt

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Big Data Get it?

Slide 8

Slide 8 text

IBM Cloud Data Services Open for Data A comprehensive por.olio of open source data services

Slide 9

Slide 9 text

A Brief History of Data

Slide 10

Slide 10 text

The Relational Database @BradleyHolt order *order_id customer_id date customer line_item *customer_id email_address name *order_id *item_id price quantity

Slide 11

Slide 11 text

ACID Guarantees Relational databases guarantee atomicity, consistency, isolation and durability

Slide 12

Slide 12 text

Big Iron The ACID guarantees provided by relational databases were (and often still are) critical for systems of record

Slide 13

Slide 13 text

The World Wide Web The introduction of the Web brought a whole new type of application with different constraints than systems of record @BradleyHolt

Slide 14

Slide 14 text

Mobile Apps The introduction of mobile apps added to the growing number of systems of engagement

Slide 15

Slide 15 text

Changing Constraints

Slide 16

Slide 16 text

Always On

Slide 17

Slide 17 text

Big Data

Slide 18

Slide 18 text

The CAP Theorem @BradleyHolt Partition Tolerance Availability Consistency Consistency Availability Partition Tolerance

Slide 19

Slide 19 text

Horizontal Scaling Horizontal scaling is scaling through the addition of commodity hardware

Slide 20

Slide 20 text

Eventual Consistency Given no new updates, each node in a distributed system will eventually have a consistent view of the data

Slide 21

Slide 21 text

Enter "Not only SQL" (NoSQL)

Slide 22

Slide 22 text

@BradleyHolt key-value graph document …more

Slide 23

Slide 23 text

@BradleyHolt

Slide 24

Slide 24 text

Key-Value Stores Opaque data accessed through unique keys

Slide 25

Slide 25 text

Document Databases A variation on key-value stores with strictly defined values (e.g. JSON objects)

Slide 26

Slide 26 text

Graph Databases Nodes and properties of nodes connected via edges

Slide 27

Slide 27 text

Domain-Driven Design (DDD)

Slide 28

Slide 28 text

@BradleyHolt

Slide 29

Slide 29 text

Domain-Driven Design A collaboration between domain experts and software practitioners

Slide 30

Slide 30 text

Complexity is in the Domain Complexity is in the domain, not in the technology

Slide 31

Slide 31 text

Models as Tools Models are tools used to solve problems within the domain

Slide 32

Slide 32 text

The Map is not the Territory Don't confuse models with reality itself

Slide 33

Slide 33 text

Building Blocks of DDD and the Life Cycle of a Domain Object

Slide 34

Slide 34 text

Entities Entities are defined by their identity

Slide 35

Slide 35 text

Value Objects Value objects encode attributes that describe things

Slide 36

Slide 36 text

Aggregates Aggregates group related entities to minimize complexity

Slide 37

Slide 37 text

Repositories A repository provides the illusion of an in-memory data store

Slide 38

Slide 38 text

Domain Layer Order Aggregate @BradleyHolt «interface» OrderRepository + insertOrder(order:Order) + updateOrder(order:Order) + findOrderById(id:int) : Order + recentOrders([limit:int]) : Order[0..*] Customer … Infrastructure Layer LineItem … Order - id : int - customer : Customer - date : Date - lineItems : LineItem[1..*] + total() : Money InMemoryOrderRepository + insertOrder(order:Order) + updateOrder(order:Order) + findOrderById(id:int) : Order + recentOrders(limit:int) : Order[0..*] RelationalMapperOrderRepository + insertOrder(order:Order) + updateOrder(order:Order) + findOrderById(id:int) : Order + recentOrders(limit:int) : Order[0..*]

Slide 39

Slide 39 text

Choosing the Right Data Layer

Slide 40

Slide 40 text

Data Store A repository cannot abstract the constraints of your data store

Slide 41

Slide 41 text

Object-Relational Impedance Mismatch Object-oriented programming and relational databases use different models

Slide 42

Slide 42 text

Eric Evans on NoSQL "This is the world of NoSQL to me, that we can choose a tool that fits well with the problem we're trying to solve." –Eric Evans (author of Domain-Driven Design) @BradleyHolt

Slide 43

Slide 43 text

Strategic Design

Slide 44

Slide 44 text

Bounded Context Bounded contexts allow different domain models to be used within different contexts

Slide 45

Slide 45 text

One Data Layer Per Bounded Context Each bounded context should have its own data layer, and should not directly access a data layer belonging to another bounded context

Slide 46

Slide 46 text

Data Systems A data layer may be a database, or it can be a data system consisting of multiple databases

Slide 47

Slide 47 text

Microservices as Bounded Context Represent each bounded context as a microservice or a cluster of microservices

Slide 48

Slide 48 text

@BradleyHolt Catalog Document Database Key/Value Store Graph Database Full Text Search Shopping Cart Document Database Key/Value Store Orders Relational Database Big Data Analytics

Slide 49

Slide 49 text

Alternative Architectures

Slide 50

Slide 50 text

Command Query Responsibility Segregation (CQRS) Rather than update an entity in place, CQRS provides separate read and write models

Slide 51

Slide 51 text

Domain Layer @BradleyHolt Read Model «interface» OrderQueryHandler + findOrderById(id:int) : OrderDetails + recentOrders([limit:int]) : OrderSummary[0..*] Write Model OrderDetails + getId() : int + getCustomer() : Customer + getDate() : Date + getLineItems() : LineItem[1..*] + getTotal() : Money «interface» OrderCommandHandler + handle(command:CreateOrder) + handle(command:AddLineItem) CreateOrder - customer : Customer - date : Date - lineItems : LineItem[1..*] OrderSummary + getId() : int + getDate() : Date + getTotal() : Money AddLineItem - orderId : int - lineItem : LineItem

Slide 52

Slide 52 text

Event Sourcing The current application state is computed from a sequence of events

Slide 53

Slide 53 text

IBM Cloud Data Services Open for Data A comprehensive por.olio of open source data services

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

Image Credits §  Open for Data Dome (outside) by Bradley Holt §  Open for Data Dome (inside) by Bradley Holt §  Brent Spiner (Data from Star Trek: The Next Generation) with Zoltar from Big by Bradley Holt, on Twitter §  database 2 by Tim Morgan, on Flickr §  Hard Disk by Jeff Kubina, on Flickr §  IBM 360 Announcement center by Robert Nix, on Flickr §  Dialing Up Web History by Mike Licht, on Flickr §  Instagram and other Social Media Apps by Jason Howie, on Flickr §  Dynamo, un siècle de lumière et de mouvement dans l'art, 1913 – 2013 - Galeries nationales du Grand Palais - Paris - 10 avril au 22 juillet 2013 by Yann Caradec, on Flickr §  Server grill with blue light by David Precious, on Flickr §  Spider Web by Alden Chadwick, on Flickr §  database by Tim Morgan, on Flickr §  Keys for the Stanley Hotel by Mike Silva, on Flickr §  paper by malik, on Flickr §  Edinburgh Road Network analysis by Steven Kay, on Flickr @BradleyHolt

Slide 56

Slide 56 text

Image Credits (cont'd) §  IMG_2619 by Jason Pelletier, on Flickr §  Sounds_of_Complexity11.jpg by Enzo Varriale, on Flickr §  model by MaZzuk, on Flickr §  taking the subway to find the rents by Eli Duke, on Flickr §  DSC_3407 by Mad House Photography, on Flickr §  red numbers by DaveBleasdale, on Flickr §  Social graph by Dmitry Grigoriev, on Flickr §  Catalog. by Adam Mayer, on Flickr §  Lina Bo Bardi, SESC Pompéia by paulisson miura, on Flickr §  Financial District Classical Building Reflection Distortion, San Francisco, California, USA by Wonderlane, on Flickr §  Eric Evans by Oliver Gierke, on Flickr §  rectangles by Dean Hochman, on Flickr §  Hexagons by Henry Burrows, on Flickr §  Rooted by Anna Levinzon, on Flickr §  Rainforest Biome by BMiz, on Flickr §  rectangles-10 by Karen Cropper, on Flickr §  Rusty Chain by veggiefrog, on Flickr @BradleyHolt

Slide 57

Slide 57 text

Questions? @BradleyHolt