a practical guide to domain driven design: presentation slides

33
Jak Charlton [email protected] www.thinkddd.com Readify www.readify.net

Upload: thinkddd

Post on 10-May-2015

6.272 views

Category:

Technology


1 download

DESCRIPTION

Tonight I presented on Domain Driven Design to the Alt.Net group in Sydney at the invite of Richard Banks.As a follow up, attached are the slides I used, feel free to distribute and use on the Creative Commons Licence

TRANSCRIPT

Page 1: A Practical Guide to Domain Driven Design: Presentation Slides

Jak [email protected]

Readify www.readify.net

Page 2: A Practical Guide to Domain Driven Design: Presentation Slides

Practical Domain Driven Design

Practical Domain Driven Design

Message Based Architecture and CQRSMessage Based Architecture and CQRS

Page 3: A Practical Guide to Domain Driven Design: Presentation Slides

Domain Driven Design ISDomain Driven Design IS

An architectural methodology

for evolving a software system

that closely aligns to business requirements

An architectural methodology

for evolving a software system

that closely aligns to business requirements

Page 4: A Practical Guide to Domain Driven Design: Presentation Slides

Domain Driven Design IS NOT

Domain Driven Design IS NOT

A silver bulletA panacea for all your troublesAn easy path to followAlways the best solution

And most importantly, it is not focused on the How, but the What and Why

A silver bulletA panacea for all your troublesAn easy path to followAlways the best solution

And most importantly, it is not focused on the How, but the What and Why

Page 5: A Practical Guide to Domain Driven Design: Presentation Slides

Where Are We Going?Where Are We Going?

Page 6: A Practical Guide to Domain Driven Design: Presentation Slides

The Domain Vision Statement

The Domain Vision Statement

A shared understanding of what it is you are actually trying to create

Should be brief, written in clear English and understood by business and tech people alike

Should be factual, realistic, honest Should avoid superlatives and

marketing speak Should avoid technical and

implementation details

A shared understanding of what it is you are actually trying to create

Should be brief, written in clear English and understood by business and tech people alike

Should be factual, realistic, honest Should avoid superlatives and

marketing speak Should avoid technical and

implementation details

Page 7: A Practical Guide to Domain Driven Design: Presentation Slides

Domain = Sphere of Activity?

Domain = Sphere of Activity?

Page 8: A Practical Guide to Domain Driven Design: Presentation Slides

DomainDomain

A Domain is a Sphere of Knowledge, Influence or Activity

A Domain is represented by the Ubiquitous Language

A Domain encapsulates a Domain Model

A Domain lives within a Bounded Context

A Domain is a Sphere of Knowledge, Influence or Activity

A Domain is represented by the Ubiquitous Language

A Domain encapsulates a Domain Model

A Domain lives within a Bounded Context

Page 9: A Practical Guide to Domain Driven Design: Presentation Slides
Page 10: A Practical Guide to Domain Driven Design: Presentation Slides

The Ubiquitous LanguageThe Ubiquitous Language

A major reason for failure of software projects is a failure of people, the failure to communicate

The Ubiquitous Language is a shared language between the business and the development teams

The UL comes from the business, and is enriched by the development teams

A major reason for failure of software projects is a failure of people, the failure to communicate

The Ubiquitous Language is a shared language between the business and the development teams

The UL comes from the business, and is enriched by the development teams

Page 11: A Practical Guide to Domain Driven Design: Presentation Slides
Page 12: A Practical Guide to Domain Driven Design: Presentation Slides

Domain ExpertsDomain Experts

Domain Experts are the primary point of contact the development teams have with the business

They are the Experts on their part of the business, not just users of the system

They should have deep knowledge of the subject Domain

Domain Experts are the primary point of contact the development teams have with the business

They are the Experts on their part of the business, not just users of the system

They should have deep knowledge of the subject Domain

Page 13: A Practical Guide to Domain Driven Design: Presentation Slides

Looks Pretty Unique To MeLooks Pretty Unique To Me

Page 14: A Practical Guide to Domain Driven Design: Presentation Slides

EntitiesEntities

Entities are the “things” within your Model

An Entity is defined by being unique, and uniquely identifiable

Entities are the “things” within your Model

An Entity is defined by being unique, and uniquely identifiable

Page 15: A Practical Guide to Domain Driven Design: Presentation Slides

You Can’t Tell One From Another

You Can’t Tell One From Another

Page 16: A Practical Guide to Domain Driven Design: Presentation Slides

Value ObjectsValue Objects

Value Objects are the “things” within your model that have no uniqueness

They are equal in all ways to another Value Object if all their properties match

Value Objects are interchangeable

Value Objects are the “things” within your model that have no uniqueness

They are equal in all ways to another Value Object if all their properties match

Value Objects are interchangeable

Page 17: A Practical Guide to Domain Driven Design: Presentation Slides

How Can We Make Sense?

Page 18: A Practical Guide to Domain Driven Design: Presentation Slides

Domain ModelDomain Model

A Domain Model is a representation of the relationships between the Entities and Value Objects in your Domain

It may look similar to UML or a class relationship diagram, but it is not one

The Domain Model should be recognisable and understandable by the business

A Domain Model is a representation of the relationships between the Entities and Value Objects in your Domain

It may look similar to UML or a class relationship diagram, but it is not one

The Domain Model should be recognisable and understandable by the business

Page 19: A Practical Guide to Domain Driven Design: Presentation Slides

That’s a Lot of BitsThat’s a Lot of Bits

Page 20: A Practical Guide to Domain Driven Design: Presentation Slides

AggregatesAggregates

“An aggregate is a collection of items that are gathered together to form a total quantity” - Wikipedia

An Aggregate Root is the root item containing a number of parts that form a whole

An AR is more likely to match a Use Case than any model structure

“An aggregate is a collection of items that are gathered together to form a total quantity” - Wikipedia

An Aggregate Root is the root item containing a number of parts that form a whole

An AR is more likely to match a Use Case than any model structure

Page 21: A Practical Guide to Domain Driven Design: Presentation Slides
Page 22: A Practical Guide to Domain Driven Design: Presentation Slides

Bounded ContextsBounded Contexts

When you have multiple models you should consider Bounded Contexts

Each BC is a self contained “mini application” containing it’s own model, persistence and code base

To map between BCs you use a Context Map

When you have multiple models you should consider Bounded Contexts

Each BC is a self contained “mini application” containing it’s own model, persistence and code base

To map between BCs you use a Context Map

Page 23: A Practical Guide to Domain Driven Design: Presentation Slides
Page 24: A Practical Guide to Domain Driven Design: Presentation Slides

Anti-Corruption LayersAnti-Corruption Layers

An Anti-Corruption Layer is a method to isolate two systems, allowing systems to be integrated without knowledge of each other

An ACL presents a Facade to both systems, defined in terms of their specific models

ACLs maintain the integrity of a Domain

An Anti-Corruption Layer is a method to isolate two systems, allowing systems to be integrated without knowledge of each other

An ACL presents a Facade to both systems, defined in terms of their specific models

ACLs maintain the integrity of a Domain

Page 25: A Practical Guide to Domain Driven Design: Presentation Slides
Page 26: A Practical Guide to Domain Driven Design: Presentation Slides

Persistence IgnorancePersistence Ignorance

Subtitled “There Is No Database” DDD uses the Repository pattern

to create Persistence IgnoranceA Repository represents itself as

an in-memory list of itemsRepositories are specific to

Aggregate Roots, not to Entities

Subtitled “There Is No Database” DDD uses the Repository pattern

to create Persistence IgnoranceA Repository represents itself as

an in-memory list of itemsRepositories are specific to

Aggregate Roots, not to Entities

Page 27: A Practical Guide to Domain Driven Design: Presentation Slides
Page 28: A Practical Guide to Domain Driven Design: Presentation Slides

Factors For Success of DDD

Factors For Success of DDD

Your domain is not trivialYou have access to Domain

ExpertsYou have an iterative processYou have a skilled and motivated

team

Your domain is not trivialYou have access to Domain

ExpertsYou have an iterative processYou have a skilled and motivated

team

Page 29: A Practical Guide to Domain Driven Design: Presentation Slides

Messaging ArchitecturesMessaging Architectures

DDD is ideally suited to Message Based Architectures

DDD is ideally suited to Commands and Events

DDD is ideally suited to providing multiple autonomous systems that are loosely coupled

DDD is ideally suited to Message Based Architectures

DDD is ideally suited to Commands and Events

DDD is ideally suited to providing multiple autonomous systems that are loosely coupled

Page 30: A Practical Guide to Domain Driven Design: Presentation Slides

Command Query Responsibility Separation

(CQRS)

Command Query Responsibility Separation

(CQRS)Bertrand Meyer principle of CQS:

every method should either be a command that performs an action, or a query that returns data to the caller

At an architectural level this means:either issue commands, or issue queries, but never both

And, query from a separate source from your domain commands

Bertrand Meyer principle of CQS:every method should either be a command that performs an action, or a query that returns data to the caller

At an architectural level this means:either issue commands, or issue queries, but never both

And, query from a separate source from your domain commands

Page 31: A Practical Guide to Domain Driven Design: Presentation Slides

CQRS in a PictureCQRS in a Picture

Page 32: A Practical Guide to Domain Driven Design: Presentation Slides
Page 33: A Practical Guide to Domain Driven Design: Presentation Slides

Jak [email protected]

Readify www.readify.net