Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf ·...

Post on 11-Jun-2020

2 views 0 download

Transcript of Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf ·...

DDD

Where’s the value and what’s

in it for me?

Dino Esposito

JetBrains

dino.esposito@jetbrains.com

@despos

facebook.com/naa4e

What does a software

architect do?

Design software driven bythe requirements of users

the characteristics of the business domain

the time we have

the money we’ve been told we’ll get

Let’s talk user requirementsTend to focus on the vision each user has of the system

Tend to blink at technical solutions (usually trivial)

Tend to minimize the number of aspects/features to consider

Constantly incomplete, inaccurate and ambiguous

Let’s talk business domainThere are no two identical business domains that are the same

A business domain is larger than the system we’re building

Take to abstract data and behaviour and generalize too much

Hard to fully comprehend unless you’re an expert already

We deliver software that works

but not in the way customers like

BLACK

MAGIC

CAREFULLY

CRAFTED

DATA MODEL

SURE WE AREN’T SCREWING IT UP

ENTIRELY ?

After decades of relational programming,

the current generation of architects grew

up with the obsession of data models.

The obsession of data models brought to

creating object models where objects are

designed to contain data rather than to

expose some behavior.

Hello!

I’m an object

Get/Set

my properties for free!

Hello!

I implement

some behavior

Pass data

and I’ll do the rest!

DOMAIN DRIVEN DESIGN

is much more serious a thing than just

having an object-oriented model for a

bunch of business entities

Domain Driven Design

Tackling complexity in the heart of software

RESULTS

Not actually cheating; not completely clear

Not hard to do right; easier to do wrong

An approach to software design and development

introduced 10+ years ago with the intent of …

Common Understanding of DDD

Behavior is all that matters

Properties should be read-only

We got to use an O/RM

The database? It doesn’t

matter

All of your classes

in a domain model

should have a

factory …

Domain model is NOT simply a fancy object model.

Domain model is NOT the starting point of DDD.

Domain model is ONE of the possible ending points.

DDD Strategic Design

Ubiquitous Language

Bounded Context

Context Map

SHARED VOCABULARY of TERMS

Dev

teams

Domain

experts

Mapping to

technical

actions (e.g., cache,

security, database)

Referring

to key

business

concepts

Dynamically Changing Grammar

Vocabulary of valid words (nouns and verbs)

Formal grammar for generating valid

expressions out of valid words

Not all verbs can be used with all nouns

Accept an invoice is valid

Accept an order is not valid

When in Rome … do as the Romans do

Cancel the booking

Checkout

Extend the job order

Register/Accept the invoice

Delete the booking

Submit the order

Update the job order

Create the invoice

Set state of the game Start/Pause the game

Management

Saved to a wiki (or Excel/OneNote)Each term fully explained, understandable to both domain

and software experts

Kept it up-to-date (not a static thing) Evolve as new insights are gained about the domain

Responsibility of the development team

Ubiquitous ≈ Used Everywhere

User Stories & RFC

Meetings

Emails

Technical Documentation

Schedule

Source codeSource code

Not a freaky new name for

naming conventions.

Use the model as the backbone

of a language.—Eric Evans

Use the language as the backbone of a model.

Acronyms

Human

language of

words

Bounded ContextBounded Context

Domain Domain Model

Problem Space Solution Space

SubdomainSubdomain

Splitting a Domain in Contexts

BUSINESS DOMAIN

Bounded Context

Ubiquitous language

Independent implementation

External interface(to other contexts)

You find a bounded context

when the ubiquitous language change.

When the language changes …

A word is discovered to have different meanings or

different representations

“Customer” means X to user 1 and Y to user 2

Different users use different words for the same concept

User 1 refers to customers as “users”. User 2 refers to

customers as “members”

Different users use different “algorithms” for the same

task and introduce different entities

User 1 knows about check-in. User 2 doesn’t use any similar

concept in the same business domain

Concrete examples of a bounded context

Legacy system

External system

Critical system to

better treat separately

Frontend

Shopping cart

Processing logic

Accounting

Backoffice

Business rules

(discounts, configuration,

personalization)

Shipping

External

system

Persistence

Payment

External

system

FRONTEND

SHOPPING CART

Application logic

BACKOFFICE

ACCOUNTING

PAYMENT SHIPPING

BIZ RULES

PERSISTENCE

SHIPPING

gateway

PAYMENT

gateway

d

u

u

d

u

u

dd

partner

supplier

supplier

conformist

supplier

Relationships

• Downstream context depends on upstream context

• No negotiation possibleConformist

• Customer context depends on supplier context

• Chance to raise concerns and have them addressed in some way

Customer/Supplier

• Mutual dependency between the two contexts Partner

• Shared model that can’t be changed without consulting teams in charge of contexts that depend on it. Shared Kernel

• Additional layer giving the downstream context a fixed interface no matter what happens in the upstream contextAnti-corruption Layer

UX-driven Design in 3 steps

PRESENTATION

collection of screens

REST OF THE SYSTEM

INPUT MODEL

VIEW MODEL

PRESENTATION

collection of screens

APPLICATION LAYER

endpoints invoked from controllers

INPUT MODEL

VIEW MODEL

REST OF THE SYSTEM

ASP.NET

MVC

CONTROLLERS

RAZOR views

Application Services

Tasks | Workflows

WHATEVER YOU HAVE

ASP.NET

MVC

CONTROLLERS

RAZOR views

Application Services

Tasks | Workflows

WHATEVER YOU HAVE

SINGLE-TIER

ASP.NET MVC or

ASP.NET CORE

SINGLE-TIER

ASP.NET MVC or

ASP.NET CORE

SINGLE-TIER

ASP.NET MVC or

ASP.NET CORE

SINGLE-TIER

ASP.NET MVC or

ASP.NET CORE

WHATEVER YOU

HAVE

http://naa4e.codeplex.com

http://www.pluralsight.com/courses/

modern-software-architecture-

domain-models-cqrs-event-

sourcing

Modern Software Architecture

FOLLOW

That’s All Folks!

facebook.com/naa4e

software2cents.wordpress.com

dino.esposito@jetbrains.com

@despos