Always Learning

Advanced Search

Implementing Domain-Driven Design

Implementing Domain-Driven Design

Vaughn Vernon

Feb 2013, Hardback, 656 pages
ISBN13: 9780321834577
ISBN10: 0321834577
Special online offer - Save 30%
Was 50.99, Now 35.69Save: 15.30
 
This title is available in the following formats:
Format RRPYour Price
Hardback £50.99 £35.69
eBook £28.99 £20.29
CourseSmart eTextbook £28.99 £20.29
  • Print pagePrint page
  • Email this pageEmail page
  • Share

“For software developers of all experience levels looking to improve their results, and design and implement domain-driven enterprise applications consistently with the best current state of professional practice, Implementing Domain-Driven Design will impart a treasure trove of knowledge hard won within the DDD and enterprise application architecture communities over the last couple decades.”

–Randy Stafford, Architect At-Large, Oracle Coherence Product Development

“This book is a must-read for anybody looking to put DDD into practice.”

–Udi Dahan, Founder of NServiceBus

Implementing Domain-Driven Design presents a top-down approach to understanding domain-driven design (DDD) in a way that fluently connects strategic patterns to fundamental tactical programming tools. Vaughn Vernon couples guided approaches to implementation with modern architectures, highlighting the importance and value of focusing on the business domain while balancing technical considerations.

Building on Eric Evans’ seminal book, Domain-Driven Design, the author presents practical DDD techniques through examples from familiar domains. Each principle is backed up by realistic Java examples–all applicable to C# developers–and all content is tied together by a single case study: the delivery of a large-scale Scrum-based SaaS system for a multitenant environment.

The author takes you far beyond “DDD-lite” approaches that embrace DDD solely as a technical toolset, and shows you how to fully leverage DDD’s “strategic design patterns” using Bounded Context, Context Maps, and the Ubiquitous Language. Using these techniques and examples, you can reduce time to market and improve quality, as you build software that is more flexible, more scalable, and more tightly aligned to business goals.

Coverage includes

  • Getting started the right way with DDD, so you can rapidly gain value from it
  • Using DDD within diverse architectures, including Hexagonal, SOA, REST, CQRS, Event-Driven, and Fabric/Grid-Based
  • Appropriately designing and applying Entities–and learning when to use Value Objects instead
  • Mastering DDD’s powerful new Domain Events technique
  • Designing Repositories for ORM, NoSQL, and other databases

Foreword xvii

Preface xix

Acknowledgments xxix

About the Author xxxiii

Guide to This Book xxxv

Chapter 1: Getting Started with DDD 1

Can I DDD? 2

Why You Should Do DDD 6

How to Do DDD 20

The Business Value of Using DDD 25

The Challenges of Applying DDD 29

Fiction, with Bucketfuls of Reality 38

Wrap-Up 41

Chapter 2: Domains, Subdomains, and Bounded Contexts 43

Big Picture 43

Why Strategic Design Is So Incredibly Essential 53

Real-World Domains and Subdomains 56

Making Sense of Bounded Contexts 62

Sample Contexts 72

Wrap-Up 84

Chapter 3: Context Maps 87

Why Context Maps Are So Essential 87

Wrap-Up 111

Chapter 4: Architecture 113

Interviewing the Successful CIO 114

Layers 119

Hexagonal or Ports and Adapters 125

Service-Oriented 130

Representational State Transfer–REST 133

Command-Query Responsibility Segregation, or CQRS 138

Event-Driven Architecture 147

Data Fabric and Grid-Based Distributed Computing 163

Wrap-Up 168

Chapter 5: Entities 171

Why We Use Entities 171

Unique Identity 173

Discovering Entities and Their Intrinsic Characteristics 191

Wrap-Up 217

Chapter 6: Value Objects 219

Value Characteristics 221

Integrate with Minimalism 232

Standard Types Expressed as Values 234

Testing Value Objects 239

Implementation 243

Persisting Value Objects 248

Wrap-Up 263

Chapter 7: Services 265

What a Domain Service Is (but First, What It Is Not) 267

Make Sure You Need a Service 268

Modeling a Service in the Domain 272

Testing Services 281

Wrap-Up 284

Chapter 8: Domain Events 285

The When and Why of Domain Events 285

Modeling Events 288

Publishing Events from the Domain Model 296

Spreading the News to Remote Bounded Contexts 303

Event Store 307

Architectural Styles for Forwarding Stored Events 312

Implementation 318

Wrap-Up 331

Chapter 9: Modules 333

Designing with Modules 333

Basic Module Naming Conventions 336

Module Naming Conventions for the Model 337

Modules of the Agile Project Management Context 340

Modules in Other Layers 343

Module before Bounded Context 344

Wrap-Up 345

Chapter 10: Aggregates 347

Using Aggregates in the Scrum Core Domain 348

Rule: Model True Invariants in Consistency Boundaries 353

Rule: Design Small Aggregates 355

Rule: Reference Other Aggregates by Identity 359

Rule: Use Eventual Consistency Outside the Boundary 364

Reasons to Break the Rules 367

Gaining Insight through Discovery 370

Implementation 380

Wrap-Up 388

Chapter 11: Factories 389

Factories in the Domain Model 389

Factory Method on Aggregate Root 391

Factory on Service 397

Wrap-Up 400

Chapter 12: Repositories 401

Collection-Oriented Repositories 402

Persistence-Oriented Repositories 418

Additional Behavior 430

Managing Transactions 432

Type Hierarchies 437

Repository versus Data Access Object 440

Testing Repositories 441

Wrap-Up 448

Chapter 13: Integrating Bounded Contexts 449

Integration Basics 450

Integration Using RESTful Resources 458

Integration Using Messaging 469

Wrap-Up 508

Chapter 14: Application 509

User Interface 512

Application Services 521

Composing Multiple Bounded Contexts 531

Infrastructure 532

Enterprise Component Containers 534

Wrap-Up 537

Appendix A: Aggregates and Event Sourcing: A+ES 539

Inside an Application Service 541

Command Handlers 549

Lambda Syntax 553

Concurrency Control 554

Structural Freedom with A+ES 558

Performance 558

Implementing an Event Store 561

Relational Persistence 565

BLOB Persistence 568

Focused Aggregates 569

Read Model Projections 570

Use with Aggregate Design 573

Events Enrichment 573

Supporting Tools and Patterns 576

Contract Generation 580

Unit Testing and Specifications 582

Event Sourcing in Functional Languages 583

Bibliography 585

Index 589

Vaughn Vernon is a veteran software craftsman with more than twenty-five years of experience in software design, development, and architecture. He is a thought leader in simplifying software design and implementation using innovative methods. He has been programming with object-oriented languages since the 1980s, and applying the tenets of Domain-Driven Design since his Smalltalk domain modeling days in the early 1990s. He consults and speaks internationally, and has taught his Implementing Domain-Driven Design classes on multiple continents.

“With Implementing Domain-Driven Design, Vaughn has made an important contribution not only to the literature of the Domain-Driven Design community, but also to the literature of the broader enterprise application architecture field. In key chapters on Architecture and Repositories, for example, Vaughn shows how DDD fits with the expanding array of architecture styles and persistence technologies for enterprise applications—including SOA and REST, NoSQL and data grids—that has emerged in the decade since Eric Evans’ seminal book was first published. And, fittingly, Vaughn illuminates the blocking and tackling of DDD—the implementation of entities, value objects, aggregates, services, events, factories, and repositories—with plentiful examples and valuable insights drawn from decades of practical experience. In a word, I would describe this book as thorough. For software developers of all experience levels looking to improve their results, and design and implement domain-driven enterprise applications consistently with the best current state of professional practice, Implementing Domain-Driven Design will impart a treasure trove of knowledge hard won within the DDD and enterprise application architecture communities over the last couple decades.”

—Randy Stafford, Architect At-Large, Oracle Coherence Product Development


“Domain-Driven Design is a powerful set of thinking tools that can have a profound impact on how effective a team can be at building software-intensive systems. The thing is that many developers got lost at times when applying these thinking tools and really needed more concrete guidance. In this book, Vaughn provides the missing links between theory and practice. In addition to shedding light on many of the misunderstood elements of DDD, Vaughn also connects new concepts like Command/Query Responsibility Segregation and Event Sourcing that many advanced DDD practitioners have used with great success. This book is a must-read for anybody looking to put DDD into practice.”

—Udi Dahan, Founder of NServiceBus


“For years, developers struggling to practice Domain-Driven Design have been wishing for more practical help in actually implementing DDD. Vaughn did an excellent job in closing the gap between theory and practice with a complete implementation reference. He paints a vivid picture of what it is like to do DDD in a contemporary project, and provides plenty of practical advice on how to approach and solve typical challenges occurring in a project life cycle.”

— Alberto Brandolini, DDD Instructor, Certified by Eric Evans and Domain Language, Inc.


Implementing Domain-Driven Design does a remarkable thing: it takes a sophisticated and substantial topic area in DDD and presents it clearly, with nuance, fun and finesse. This book is written in an engaging and friendly style, like a trusted advisor giving you expert counsel on how to accomplish what is most important. By the time you finish the book you will be able to begin applying all the important concepts of DDD, and then some. As I read, I found myself highlighting many sections . . . I will be referring back to it, and recommending it, often.”

— Paul Rayner, Principal Consultant & Owner, Virtual Genius, LLC., DDD Instructor, Certified by Eric Evans and Domain Language, Inc., DDD Denver Founder and Co-leader

“One important part of the DDD classes I teach is discussing how to put all the ideas and pieces together into a full blown working implementation. With this book, the DDD community now has a comprehensive reference that addresses this in detail. Implementing Domain-Driven Design deals with all aspects of building a system using DDD, from getting the small details right to keeping track of the big picture. This is a great reference and an excellent companion to Eric Evans seminal DDD book.”

— Patrik Fredriksson, DDD Instructor, Certified by Eric Evans and Domain Language, Inc.


“If you care about software craftsmanship—and you should—then Domain-Driven Design is a crucial skill set to master and Implementing Domain-Driven Design is the fast path to success. IDDD offers a highly readable yet rigorous discussion of DDD’s strategic and tactical patterns that enables developers to move immediately from understanding to action. Tomorrow’s business software will benefit from the clear guidance provided by this book.”

—Dave Muirhead, Principal Consultant, Blue River Systems Group


“There’s theory and practice around DDD that every developer needs to know, and this is the missing piece of the puzzle that puts it all together. Highly recommended!”

—Rickard Öberg, Java Champion and Developer at Neo Technology


“In IDDD, Vaughn takes a top-down approach to DDD, bringing strategic patterns such as bounded context and context maps to the fore, with the building block patterns of entities, values and services tackled later. His book uses a case study throughout, and to get the most out of it you’ll need to spend time grokking that case study. But if you do you’ll be able to see the value of applying DDD to a complex domain; the frequent sidenotes, diagrams, tables, and code all help illustrate the main points. So if you want to build a solid DDD system employing the architectural styles most commonly in use today, Vaughn’s book comes recommended.”

—Dan Haywood, author of Domain-Driven Design with Naked Objects


“This book employs a top-down approach to understanding DDD in a way that fluently connects strategic patterns to lower level tactical constraints. Theory is coupled with guided approaches to implementation within modern architectural styles. Throughout the book, Vaughn highlights the importance and value of focusing on the business domain all while balancing technical considerations. As a result, the role of DDD, as well as what it does and perhaps more importantly doesn’t imply, become ostensibly clear. Many a time, my team and I would be at odds with the friction encountered in applying DDD. With Implementing Domain-Driven Design as our luminous guide we were able to overcome those challenges and translate our efforts into immediate business value.”

—Lev Gorodinski, Principal Architect, DrillSpot.com