Designing a Serverless Application with Domain Driven Design - - PowerPoint PPT Presentation

designing a serverless application with domain driven
SMART_READER_LITE
LIVE PREVIEW

Designing a Serverless Application with Domain Driven Design - - PowerPoint PPT Presentation

Designing a Serverless Application with Domain Driven Design Susanne Kaiser Independent Tech Consultant @suksr Costs of Poor Software Quality in the US in 2018 (by CISQ report ) $2,840,000,000,000 TWOTRILLIONEIGHTHUNDREDFOURTYBILLION USD


slide-1
SLIDE 1

Designing a Serverless Application with Domain Driven Design

Susanne Kaiser Independent Tech Consultant @suksr

slide-2
SLIDE 2

$2,840,000,000,000

TWOTRILLIONEIGHTHUNDREDFOURTYBILLION USD

Costs of Poor Software Quality in the US in 2018 (by CISQ report )

Source: https://www.it-cisq.org/the-cost-of-poor-quality-software-in-the-us-a-2018-report

@suksr

slide-3
SLIDE 3

Some Indicators for Poor Software Quality (extracted from CISQ report )

t

Defects

0% Increasing defect trend Low test coverage Cyclomatic complexity Large inheritance depth High amount of effort to understand piece of code Badly engineered software Lack of domain knowledge

Based on: https://www.it-cisq.org/the-cost-of-poor-quality-software-in-the-us-a-2018-report

Communication and coordination breakdowns in (large) teams High degree of class coupling @suksr

slide-4
SLIDE 4

Domain Driven Design (DDD)

Business Domain Needs Strategy Software Design

@suksr

slide-5
SLIDE 5

Domain Driven Design (DDD) – Terminology

Strategic Design Tactical Design Bounded Context Ubiquitous Language Core Subdomain Supporting Subdomain Generic Subdomain Problem Space Solution Space Context Maps Anti-Corruption Layer Shared Kernel Open Host Service Separate Ways Partnership Customer-Supplier Conformist Domain Model Entity Value Object Aggregate Repository Factory Application Service Domain Service Domain Event

@suksr

slide-6
SLIDE 6

DDD & Wardley Maps

Value Chain

I n v i s i b l e V i s i b l e

Evolution

Genesis Custom-Built Product (+rental) Commodity (+utility) P

  • s

i t i

  • n

Movement

Uncharted Industrialised @suksr

slide-7
SLIDE 7

Value Chain

I n v i s i b l e V i s i b l e

Evolution

Visualisation of a value chain’s evolution

Genesis Custom-Built Product (+rental) Commodity (+utility) P

  • s

i t i

  • n

Movement

Wardley Maps BY SIMON WARDLEY

Uncharted Industrialised @suksr

slide-8
SLIDE 8

Wardley Maps – VALUE CHAIN

Who are your users?

Value Chain

I n v i s i b l e V i s i b l e

@suksr

slide-9
SLIDE 9

Wardley Maps – VALUE CHAIN

Who are your users? What are your users’ needs?

Value Chain

I n v i s i b l e V i s i b l e

@suksr

slide-10
SLIDE 10

Wardley Maps – VALUE CHAIN

Who are your users? What are your users’ needs? What are the components/activities to fulfill your users’ needs incl. dependencies?

Value Chain

I n v i s i b l e V i s i b l e P

  • s

i t i

  • n

@suksr

slide-11
SLIDE 11

Wardley Maps – LANDSCAPE

Value Chain

I n v i s i b l e V i s i b l e

Evolution

Components along evolution axes

Genesis Custom-Built Product (+rental) Commodity (+utility) P

  • s

i t i

  • n

Movement

@suksr

slide-12
SLIDE 12

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Everything evolves

Past Current Future

Supply Competition Demand Competition

Uncharted Industrialised

Wardley Maps – PATTERNS

Movement

@suksr

slide-13
SLIDE 13

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Past Current Future

Characteristics change

Uncharted Undefined market Uncertain Unpredictable Rare Poorly understood Forming market Learning on use Increasing understanding Slowly increasing consumption Rapid increases in learning Growing market Learning on operation Increasing education Rapidly increasing consumption Rapid increase in use Mature market Known / accepted Stable Widespread and stabilising Commonly understood (in term of use) Industrialised

Wardley Maps – PATTERNS

Movement

@suksr

slide-14
SLIDE 14

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Wardley Maps – PRINCIPLES

Use appropriate methods per evolution stage

Build in-house Use/buy off-the-shelf product Outsource to utility suppliers @suksr

slide-15
SLIDE 15

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Use appropriate methods per evolution stage

Wardley Maps – PRINCIPLES

Build in-house Use/buy off-the-shelf product Outsource to utility suppliers @suksr

slide-16
SLIDE 16

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Use appropriate methods per evolution stage

Wardley Maps – PRINCIPLES

Build in-house Use/buy off-the-shelf product Outsource to utility suppliers @suksr

slide-17
SLIDE 17

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Know your users & focus on user needs

Wardley Maps – PRINCIPLES

Build in-house / Agile Use/buy off-the-shelf product / Lean Outsource to utility suppliers / Six Sigma @suksr

slide-18
SLIDE 18

Domain Driven Design

Ubiquitous Language Domain Knowledge

Understanding the problem domain first before solving it

Problem Domain Domain Experts Development Teams Collaboration @suksr

slide-19
SLIDE 19

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

DDD & Wardley Maps

Problem Domain

Strategic Design

DDD Patterns & Practices

Tactical Design

@suksr

S t r a t e g i c D e s i g n T a c t i c a l D e s i g n

slide-20
SLIDE 20

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

DDD & Wardley Maps

Problem Domain

Strategic Design

DDD Patterns & Practices

Tactical Design

Analysing the business domain Discovering Subdomains Problem Space @suksr

P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n T a c t i c a l D e s i g n A n a l y s e & D i s c

  • v

e r

slide-21
SLIDE 21

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

DDD & Wardley Maps

Problem Domain

Strategic Design

DDD Patterns & Practices

Tactical Design

Analysing the business domain Discovering Subdomains Problem Space Decomposing into modular components (Bounded Contexts (BC)) Mapping interaction patterns between BC (Context Maps) Solution Space @suksr

P r

  • b

l e m S p a c e S

  • l

u t i

  • n

S p a c e S t r a t e g i c D e s i g n T a c t i c a l D e s i g n A n a l y s e & D i s c

  • v

e r D e c

  • m

p

  • s

e & M a p High-Level Design Decisions

slide-22
SLIDE 22

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

DDD & Wardley Maps

Problem Domain

Strategic Design

DDD Patterns & Practices

Tactical Design

Architecting a solution fitting the problem domain as closely as possible Provides building blocks to implement domain model Analysing the business domain Discovering Subdomains Problem Space Decomposing into modular components (Bounded Contexts (BC) Mapping interaction patterns between BC (Context Maps) Solution Space @suksr Solution Space

P r

  • b

l e m S p a c e S

  • l

u t i

  • n

S p a c e S t r a t e g i c D e s i g n T a c t i c a l D e s i g n A n a l y s e & D i s c

  • v

e r A r c h i t e c t & I m p l e m e n t High-Level Design Decisions Low-Level Design Decisions D e c

  • m

p

  • s

e & M a p

slide-23
SLIDE 23

A n a l y s e & D i s c

  • v

e r

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Distilling the problem domain & discovering the core subdomain

DDD & Wardley Maps

Core Subdomain Problem Domain

STRATEGIC DESIGN (PROBLEM SPACE)

Supporting Subdomain Generic Subdomain @suksr

P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n

slide-24
SLIDE 24

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Distilling the problem domain & discovering the core subdomain

DDD & Wardley Maps

Core Subdomain Problem Domain Competitive advantage Complex Changes often Build in-house

STRATEGIC DESIGN (PROBLEM SPACE)

Supporting Subdomain Generic Subdomain @suksr

A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n

Build in-house Use/buy off-the-shelf product Outsource to utility suppliers

slide-25
SLIDE 25

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Distilling the problem domain & discovering the core subdomain

DDD & Wardley Maps

Core Subdomain Problem Domain Competitive advantage Complex Changes often Build in-house No competitive advantage Quite simple Does not change often Prefer to buy/use off-the-shelf

STRATEGIC DESIGN (PROBLEM SPACE)

Supporting Subdomain Generic Subdomain @suksr

A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n

Build in-house Use/buy off-the-shelf product Outsource to utility suppliers

slide-26
SLIDE 26

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Distilling the problem domain & discovering the core subdomain

DDD & Wardley Maps

Core Subdomain Problem Domain Competitive advantage Complex Changes often Build in-house No competitive advantage Quite simple Does not change often Prefer to buy/use off-the-shelf No competitive advantage Generally complex Does not change often Buy/use off-the-shelf / outsource

STRATEGIC DESIGN (PROBLEM SPACE)

Supporting Subdomain Generic Subdomain @suksr

A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n

Build in-house Use/buy off-the-shelf product Outsource to utility suppliers

slide-27
SLIDE 27

D e c

  • m

p

  • s

e & M a p A n a l y s e & D i s c

  • v

e r

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Model Driven Design

DDD & Wardley Maps

STRATEGIC DESIGN (SOLUTION SPACE)

Development Teams Domain Experts Ubiquitous Language Analysis Model Code Model Domain Model Core Subdomain Supporting Subdomain Generic Subdomain Problem Domain abstracted by @suksr

P r

  • b

l e m S p a c e S

  • l

u t i

  • n

S p a c e S t r a t e g i c D e s i g n

slide-28
SLIDE 28

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Bounded Contexts

DDD & Wardley Maps

STRATEGIC DESIGN (SOLUTION SPACE)

Core Subdomain Supporting Subdomain Generic Subdomain Problem Domain Linguistic/semantic boundary Ownership boundary Model integrity boundary Physical boundary Different architectural patterns per context possible @suksr

Microservice candidates

D e c

  • m

p

  • s

e & M a p A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n S

  • l

u t i

  • n

S p a c e

slide-29
SLIDE 29

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Know your users & focus on user needs

Submit Session

DDD & Wardley Maps

STRATEGIC DESIGN (PROBLEM SPACE) Speaker

@suksr

A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n

slide-30
SLIDE 30

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Speaker

Submit Session

DDD & Wardley Maps

STRATEGIC DESIGN (PROBLEM SPACE)

Discovering subdomains

Supporting Generic Core @suksr

A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n

slide-31
SLIDE 31

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Speaker

Submit Session

DDD & Wardley Maps

STRATEGIC DESIGN (SOLUTION SPACE)

Supporting Generic Core

Event Evaluation Account Schedule Message Session

Domain Models

@suksr

D e c

  • m

p

  • s

e & M a p A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S

  • l

u t i

  • n

S p a c e S t r a t e g i c D e s i g n

slide-32
SLIDE 32

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Speaker

Submit Session

DDD & Wardley Maps

Supporting Generic Core

Event Evaluation Account Schedule Message Speaker Session CfP

STRATEGIC DESIGN (SOLUTION SPACE)

Domain Models

@suksr

D e c

  • m

p

  • s

e & M a p A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n S

  • l

u t i

  • n

S p a c e

slide-33
SLIDE 33

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Speaker

Submit Session

DDD & Wardley Maps

Supporting Generic Core

Event Evaluation Account Schedule Message Speaker Profile Submitted Session CfP Settings Recipient Open CfP Evaluated Session Scheduled Session

STRATEGIC DESIGN (SOLUTION SPACE)

Domain Models

@suksr

D e c

  • m

p

  • s

e & M a p A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n S

  • l

u t i

  • n

S p a c e

slide-34
SLIDE 34

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Speaker

Submit Session

DDD & Wardley Maps

Supporting Generic Core

STRATEGIC DESIGN (SOLUTION SPACE)

Bounded Contexts

Linguistic/semantic boundary Model integrity boundary

Event Evaluation Account Schedule Message Submitted Session CfP Settings Recipient Open CfP Evaluated Session Scheduled Session Speaker Profile Session Evaluation Submission Handling Event Mngmnt. Schedule Mngmnt. Messaging Account Handling

@suksr

D e c

  • m

p

  • s

e & M a p A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n S

  • l

u t i

  • n

S p a c e

slide-35
SLIDE 35

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Speaker

Submit Session

DDD & Wardley Maps

Supporting Generic Core

STRATEGIC DESIGN (SOLUTION SPACE)

Submission Handling Event Mngmnt. Session Evaluation Messaging Account Handling Schedule Mngmnt.

Bounded Contexts

Ownership boundary Linguistic/semantic boundary Model integrity boundary @suksr

D e c

  • m

p

  • s

e & M a p A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n S

  • l

u t i

  • n

S p a c e

slide-36
SLIDE 36

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Speaker

Submit Session

DDD & Wardley Maps

Supporting Generic Core

STRATEGIC DESIGN (SOLUTION SPACE)

Submission Handling Event Mngmnt. Session Evaluation Messaging Account Handling Schedule Mngmnt.

Bounded Contexts

Ownership boundary Linguistic/semantic boundary Model integrity boundary Physical boundary

SCM Data store CI/CD Artefact

@suksr

D e c

  • m

p

  • s

e & M a p A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S t r a t e g i c D e s i g n S

  • l

u t i

  • n

S p a c e

slide-37
SLIDE 37

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Speaker

Submit Session

DDD & Wardley Maps

Supporting Generic Core

TACTICAL DESIGN

Submission Handling Event Mngmnt. Session Evaluation Messaging Account Handling Schedule Mngmnt.

Architectural Patterns

Architectural patterns can differ per Bounded Context, e.g.

Layered Architecture Hexagonal Architecture CQRS

@suksr

D e c

  • m

p

  • s

e & M a p A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S

  • l

u t i

  • n

S p a c e S t r a t e g i c D e s i g n T a c t i c a l D e s i g n A r c h i t e c t & I m p l e m e n t

slide-38
SLIDE 38

Hexagonal Architecture

Business Logic Application REST-API Port Port

Message Broker

Adapter Adapter Adapter Port Inner Outer Outside

@suksr

slide-39
SLIDE 39

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Speaker

Submit Session

DDD & Wardley Maps

Supporting Generic Core

TACTICAL DESIGN

Submission Handling Event Mngmnt. Session Evaluation Messaging Account Handling Schedule Mngmnt.

Business Logic Implementation Patterns

Business logic implementation patterns can differ per Bounded Context, e.g.

Domain Model Active Record Transaction Script

@suksr

D e c

  • m

p

  • s

e & M a p A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S

  • l

u t i

  • n

S p a c e S t r a t e g i c D e s i g n T a c t i c a l D e s i g n A r c h i t e c t & I m p l e m e n t

slide-40
SLIDE 40

Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Speaker

Submit Session

DDD & Wardley Maps

Supporting Generic Core

TACTICAL DESIGN

Submission Handling Event Mngmnt. Session Evaluation Messaging Account Handling Schedule Mngmnt.

Building Blocks of Domain Models

  • Value Object
  • Entity
  • Aggregate
  • Repository
  • ApplicationService
  • Domain Event
  • ...

@suksr Value Chain

I n v i s i b l e V i s i b l e D e c

  • m

p

  • s

e & M a p A n a l y s e & D i s c

  • v

e r P r

  • b

l e m S p a c e S

  • l

u t i

  • n

S p a c e S t r a t e g i c D e s i g n T a c t i c a l D e s i g n A r c h i t e c t & I m p l e m e n t

slide-41
SLIDE 41

Example Domain Model

Event create: Event publish reschedule rename EventId id: string Name create: Name name: string EventStatus CREATED ACTIVATED DEACTIVATED delete Description create: Description desc: string Period create: Period start: Date end: Date

Value Object Entity Aggregate Root Aggregate @suksr

EventModel

BOUNDED CONTEXT: EVENT MANAGEMENT

slide-42
SLIDE 42

Backend-API w/ Serverless

Business Logic Application Port Adapter BOUNDED CONTEXT: EVENT MANAGEMENT

EventController

AWS API Gateway

REST-API with AWS API-Gateway and AWS Lambda

EventController

AWS API Gateway

newEvent deleteEvent publishEvent POST /events DELETE /events/{id} POST /events/{id}/publish

Inner Outer Outside

@suksr

(Adapter)

EventApplicationService

(Port)

slide-43
SLIDE 43

export class EventController { private readonly eventService: EventApplicationService; public constructor(eventService: EventApplicationService) { this.eventService = eventService; } public publishEvent: Handler = async (event: APIGatewayEvent, context: Context, callback: Callback) => { if (!event.pathParameters && !event.pathParameters.id) { return callback(null, failure({ status: "error", error: "no event id specified" })); } const eventId = new EventId(event.pathParameters.id); try { await this.eventService.publishEvent(eventId); callback(null, success({ status: "ok" })); } catch(e) { return callback(null, failure({ status: "error", error: e })); } }; public newEvent: Handler = async (event: APIGatewayEvent, context: Context, callback: Callback) => { // ... // }

REST-API Adapter

Port Lambda Function Lambda Function BOUNDED CONTEXT: EVENT MANAGEMENT

@suksr

Backend-API w/ Serverless

slide-44
SLIDE 44

Application

EventController

AWS API Gateway

DynamoDBEventRepository

Event

EventApplicationService EventRepository @suksr

(Adapter) (Port) (Port) (Adapter)

Backend-API w/ Serverless

BOUNDED CONTEXT: EVENT MANAGEMENT Inner Outer Outside

slide-45
SLIDE 45

export default class EventApplicationService { private readonly eventRepository: EventRepository; constructor(eventRepository: EventRepository) { this.eventRepository = eventRepository; } public async publishEvent(id: EventId): Promise<void> { const event = await this.eventRepository.eventOfId(id); if (!event) { throw new Error("Could not publish event with id " + id + ", since event does not exist."); } event.publish(); await this.eventRepository.saveEvent(event); } public async newEvent(command: NewEventCommand): Promise<EventId> { // ... // }

ApplicationService

@suksr

Backend-API w/ Serverless

BOUNDED CONTEXT: EVENT MANAGEMENT

slide-46
SLIDE 46

Application

EventController

AWS API Gateway

DynamoDBEventRepository

Event

EventApplicationService EventRepository

(Adapter) (Port) (Port) (Adapter)

Domain Model

BC: EVENT MANAGEMENT

Event create: Event publish reschedule rename EventId id: string Name create: Name name: string EventStatus CREATED ACTIVATED DEACTIVATED deactivate Description create: Description desc: string Period create: Period start: Date end: Date

Value Object Entity Aggregate Root Aggregate @suksr

Inner Outer Outside

slide-47
SLIDE 47

export default class Event { readonly id: EventId; name: Name; description?: Description; status: EventStatus; period: Period; private constructor(id: EventId, name: Name, status: EventStatus, period: Period, description?: Description) { this.id = id; this.name = name; this.description = description; this.status = status; this.period = period; } public publish() { if (this.status === EventStatus.CLOSED) { throw new ValidationError("status","You cannot publish a closed event"); } if (this.status === EventStatus.PUBLISHED) { throw new ValidationError("status", "This event has already been published"); } this.status = EventStatus.PUBLISHED; } public static create(id: EventId, name: Name, period: Period, status?: EventStatus, description?: Description): Event { // ... // }

Aggregate @suksr

slide-48
SLIDE 48

Application

EventController

AWS API Gateway

DynamoDBEventRepository

Event

EventApplicationService EventRepository

export default interface EventRepository { saveEvent(event: Event): void; eventOfId(id: EventId): Promise<Event|null>; // ... // }

@suksr

(Adapter) (Port) (Port) (Adapter)

Inner Outer Outside

slide-49
SLIDE 49

Data Storage with AWS DynamoDB

@suksr

Application

EventController

AWS API Gateway

DynamoDBEventRepository

Event

EventApplicationService EventRepository

(Adapter) (Port) (Port) (Adapter)

Inner Outer Outside

slide-50
SLIDE 50

export default class DynamoDBEventRepository implements EventRepository { private static TABLE_NAME: string = "events"; private readonly dynamoDbClient: AWS.DynamoDB.DocumentClient; constructor() { this.dynamoDbClient = new AWS.DynamoDB.DocumentClient(); } public saveEvent(event: Event) { const params : DocumentClient.PutItemInput = { TableName: DynamoDBEventRepository.TABLE_NAME, Item: { eventId: event.id.toString(), name: event.name.value, startDate: event.period.startDate.toISOString(), endDate: event.period.endDate.toISOString(), description: event.description ? event.description.value: undefined, eventStatus: event.status, cfp: event.cfp ? { description: event.cfp.description.value, startDate: event.cfp.period.startDate.toISOString(), endDate: event.cfp.period.endDate.toISOString(), id: event.cfp.id ? event.cfp.id.toString(): null }: null } }; return this.dynamoDbClient.put(params).promise(); } public async eventOfId(id: EventId): Promise<Event|null> { // ... // }

Database Adapter

@suksr

slide-51
SLIDE 51

Application

EventController

AWS API Gateway

DynamoDBEventRepository

Event

EventApplicationService EventRepository

(Adapter) (Port) (Port) (Adapter)

Event create: Event publish reschedule rename EventId id: string Name create: Name name: string EventStatus CREATED ACTIVATED DEACTIVATED deactivate Description create: Description desc: string Period create: Period start: Date end: Date

Value Object Entity Aggregate Root Aggregate @suksr

Inner Outer Outside

slide-52
SLIDE 52

Value Chain

I n v i s i b l e V i s i b l e Genesis Custom-Built Product (+rental) Commodity (+utility)

Evolution

Evaluate Submissions Manage Event

Organiser

Build & Publish Schedule Communicate w/ Speakers Signup/Signin

Speaker

Submit Session

DDD & Wardley Maps

Supporting Generic Core

TACTICAL DESIGN

Submission Handling Event Mngmnt. Session Evaluation Messaging Account Handling Schedule Mngmnt.

DDD suits best for the core subdomain

Movement

Build in-house Use/buy off-the-shelf product Outsource to utility suppliers

  • or -
  • or -

@suksr

P r

  • b

l e m S p a c e S

  • l

u t i

  • n

S p a c e S t r a t e g i c D e s i g n T a c t i c a l D e s i g n

slide-53
SLIDE 53

Decomposing into Modular Components

Business Domain Needs Strategy Better Software Design Ubiquitous Language Domain Knowledge Domain Experts Development Teams Collaboration

Gaining Domain Knowledge Aligning Software Design to Business Domain Do not apply DDD everywhere! Focus on your core!

Core Subdomain

DDD helps with ...

@suksr Core Subdomain

Discovering the Core Subdomain

slide-54
SLIDE 54

Some References

https://learnwardleymapping.com/ https://medium.com/wardleymaps https://miro.com/blog/wardley-maps-whiteboard-canvas/ https://github.com/wardley-maps-community/awesome- wardley-maps

slide-55
SLIDE 55

Susanne Kaiser Independent Tech Consultant @suksr susanne@kaiser-consulting.net