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

39
DDD Where’s the value and what’s in it for me? Dino Esposito JetBrains dino.esposito@jetbrains.com @despos facebook.com/naa4e

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

Page 1: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

DDD

Where’s the value and what’s

in it for me?

Dino Esposito

JetBrains

[email protected]

@despos

facebook.com/naa4e

Page 2: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

What does a software

architect do?

Page 3: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 4: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 5: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 6: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number
Page 7: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

We deliver software that works

but not in the way customers like

Page 8: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

BLACK

MAGIC

CAREFULLY

CRAFTED

DATA MODEL

SURE WE AREN’T SCREWING IT UP

ENTIRELY ?

Page 9: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

After decades of relational programming,

the current generation of architects grew

up with the obsession of data models.

Page 10: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

The obsession of data models brought to

creating object models where objects are

designed to contain data rather than to

expose some behavior.

Page 11: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

Hello!

I’m an object

Get/Set

my properties for free!

Hello!

I implement

some behavior

Pass data

and I’ll do the rest!

Page 12: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

DOMAIN DRIVEN DESIGN

is much more serious a thing than just

having an object-oriented model for a

bunch of business entities

Page 13: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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 …

Page 14: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 15: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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.

Page 16: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

DDD Strategic Design

Ubiquitous Language

Bounded Context

Context Map

Page 17: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

SHARED VOCABULARY of TERMS

Dev

teams

Domain

experts

Mapping to

technical

actions (e.g., cache,

security, database)

Referring

to key

business

concepts

Page 18: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 19: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 20: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 21: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

Ubiquitous ≈ Used Everywhere

User Stories & RFC

Meetings

Emails

Technical Documentation

Schedule

Source codeSource code

Page 22: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

Not a freaky new name for

naming conventions.

Page 23: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

Use the model as the backbone

of a language.—Eric Evans

Use the language as the backbone of a model.

Page 24: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

Acronyms

Human

language of

words

Page 25: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

Bounded ContextBounded Context

Domain Domain Model

Problem Space Solution Space

SubdomainSubdomain

Page 26: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

Splitting a Domain in Contexts

BUSINESS DOMAIN

Page 27: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

Bounded Context

Ubiquitous language

Independent implementation

External interface(to other contexts)

Page 28: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

You find a bounded context

when the ubiquitous language change.

Page 29: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 30: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

Concrete examples of a bounded context

Legacy system

External system

Critical system to

better treat separately

Page 31: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

Frontend

Shopping cart

Processing logic

Accounting

Backoffice

Business rules

(discounts, configuration,

personalization)

Shipping

External

system

Persistence

Payment

External

system

Page 32: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 33: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 34: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

UX-driven Design in 3 steps

Page 35: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

PRESENTATION

collection of screens

REST OF THE SYSTEM

INPUT MODEL

VIEW MODEL

Page 36: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 37: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

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

Page 38: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

http://naa4e.codeplex.com

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

modern-software-architecture-

domain-models-cqrs-event-

sourcing

Modern Software Architecture

Page 39: Challenges of Modern Software Developmentsddconf.com/brands/sdd/library/sdd16_esposito_ddd.pdf · Tend to blink at technical solutions (usually trivial) Tend to minimize the number

FOLLOW

That’s All Folks!

facebook.com/naa4e

software2cents.wordpress.com

[email protected]

@despos