Learning Domain-Driven Design

Book description

Building software is harder than ever. As a developer, you not only have to chase ever-changing technological trends but you also need to understand the business domains behind the software. This practical book provides you with a set of core patterns, principles, and practices for analyzing business domains, understanding business strategy, and, most importantly, aligning software design with its business needs.

Author Vladik Khononov shows you how these practices lead to robust implementation of business logic and help to future-proof software design and architecture. You'll examine the relationship between DDD and other methodologies to ensure you make architectural decisions that meet business requirements. You'll also explore the real-life story of implementing DDD in a startup company.

With this book, you'll learn how to:

  • Use DDD's strategic patterns and practices as well as its tactical patterns and use cases
  • Analyze a client company's business domain and competitive strategy
  • Build a shared understanding of the business domains you encounter
  • Decompose a system into bounded contexts
  • Coordinate the work of multiple teams working together
  • Gradually start implementing domain-driven design

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
  2. Preface
    1. Why I Wrote This Book
    2. Who Should Read This Book
    3. Navigating the Book
    4. Example Domain: WolfDesk
    5. Source Code
    6. Conventions Used in This Book
    7. Using Code Examples
    8. O’Reilly Online Learning
    9. How to Contact Us
    10. Acknowledgments
  3. Introduction
  4. I. Strategic Design
  5. 1. Analyzing Business Domains
    1. What Is a Business Domain?
    2. What Is a Subdomain?
      1. Types of Subdomains
      2. Comparing Subdomains
      3. Identifying Subdomain Boundaries
    3. Domain Analysis Examples
      1. Gigmaster
      2. BusVNext
    4. Who Are the Domain Experts?
    5. Conclusion
    6. Exercises
  6. 2. Discovering Domain Knowledge
    1. Business Problems
    2. Knowledge Discovery
    3. Communication
    4. What Is a Ubiquitous Language?
    5. Language of the Business
      1. Scenarios
      2. Consistency
    6. Model of the Business Domain
      1. What Is a Model?
      2. Effective Modeling
      3. Modeling the Business Domain
      4. Continuous Effort
      5. Tools
      6. Challenges
    7. Conclusion
    8. Exercises
  7. 3. Managing Domain Complexity
    1. Inconsistent Models
    2. What Is a Bounded Context?
      1. Model Boundaries
      2. Ubiquitous Language Refined
      3. Scope of a Bounded Context
    3. Bounded Contexts Versus Subdomains
      1. Subdomains
      2. Bounded Contexts
      3. The Interplay Between Subdomains and Bounded Contexts
    4. Boundaries
      1. Physical Boundaries
      2. Ownership Boundaries
    5. Bounded Contexts in Real Life
      1. Semantic Domains
      2. Science
      3. Buying a Refrigerator
    6. Conclusion
    7. Exercises
  8. 4. Integrating Bounded Contexts
    1. Cooperation
      1. Partnership
      2. Shared Kernel
    2. Customer–Supplier
      1. Conformist
      2. Anticorruption Layer
      3. Open-Host Service
    3. Separate Ways
      1. Communication Issues
      2. Generic Subdomains
      3. Model Differences
    4. Context Map
      1. Maintenance
      2. Limitations
    5. Conclusion
    6. Exercises
  9. II. Tactical Design
  10. 5. Implementing Simple Business Logic
    1. Transaction Script
      1. Implementation
      2. It’s Not That Easy!
      3. When to Use Transaction Script
    2. Active Record
      1. Implementation
      2. When to Use Active Record
    3. Be Pragmatic
    4. Conclusion
    5. Exercises
  11. 6. Tackling Complex Business Logic
    1. History
    2. Domain Model
      1. Implementation
      2. Building Blocks
      3. Managing Complexity
    3. Conclusion
    4. Exercises
  12. 7. Modeling the Dimension of Time
    1. Event Sourcing
      1. Search
      2. Analysis
      3. Source of Truth
      4. Event Store
    2. Event-Sourced Domain Model
      1. Advantages
      2. Disadvantages
    3. Frequently Asked Questions
      1. Performance
      2. Deleting Data
      3. Why Can’t I Just…?
    4. Conclusion
    5. Exercises
  13. 8. Architectural Patterns
    1. Business Logic Versus Architectural Patterns
    2. Layered Architecture
      1. Presentation Layer
      2. Business Logic Layer
      3. Data Access Layer
      4. Communication Between Layers
      5. Variation
      6. When to Use Layered Architecture
      7. Optional: Layers Versus Tiers
    3. Ports & Adapters
      1. Terminology
      2. Dependency Inversion Principle
      3. Integration of Infrastructural Components
      4. Variants
      5. When to Use Ports & Adapters
    4. Command-Query Responsibility Segregation
      1. Polyglot Modeling
      2. Implementation
      3. Projecting Read Models
      4. Challenges
      5. Model Segregation
      6. When to Use CQRS
    5. Scope
    6. Conclusion
    7. Exercises
  14. 9. Communication Patterns
    1. Model Translation
      1. Stateless Model Translation
      2. Stateful Model Translation
    2. Integrating Aggregates
      1. Outbox
      2. Saga
      3. Process Manager
    3. Conclusion
    4. Exercises
  15. III. Applying Domain-Driven Design in Practice
  16. 10. Design Heuristics
    1. Heuristic
    2. Bounded Contexts
    3. Business Logic Implementation Patterns
    4. Architectural Patterns
    5. Testing Strategy
      1. Testing Pyramid
      2. Testing Diamond
      3. Reversed Testing Pyramid
    6. Tactical Design Decision Tree
    7. Conclusion
    8. Exercises
  17. 11. Evolving Design Decisions
    1. Changes in Domains
      1. Core to Generic
      2. Generic to Core
      3. Supporting to Generic
      4. Supporting to Core
      5. Core to Supporting
      6. Generic to Supporting
    2. Strategic Design Concerns
    3. Tactical Design Concerns
      1. Transaction Script to Active Record
      2. Active Record to Domain Model
      3. Domain Model to Event-Sourced Domain Model
      4. Generating Past Transitions
      5. Modeling Migration Events
    4. Organizational Changes
      1. Partnership to Customer–Supplier
      2. Customer–Supplier to Separate Ways
    5. Domain Knowledge
    6. Growth
      1. Subdomains
      2. Bounded Contexts
      3. Aggregates
    7. Conclusion
    8. Exercises
  18. 12. Event Storming
    1. What Is Event Storming?
    2. Who Should Participate in Event Storming?
    3. What Do You Need for Event Storming?
    4. The Event Storming Process
      1. Step 1: Unstructured Exploration
      2. Step 2: Timelines
      3. Step 3: Pain Points
      4. Step 4: Pivotal Events
      5. Step 5: Commands
      6. Step 6: Policies
      7. Step 7: Read Models
      8. Step 8: External Systems
      9. Step 9: Aggregates
      10. Step 10: Bounded Contexts
    5. Variants
    6. When to Use Event Storming
    7. Facilitation Tips
      1. Watch the Dynamics
      2. Remote Event Storming
    8. Conclusion
    9. Exercises
  19. 13. Domain-Driven Design in the Real World
    1. Strategic Analysis
      1. Understand the Business Domain
      2. Explore the Current Design
    2. Modernization Strategy
      1. Strategic Modernization
      2. Tactical Modernization
      3. Cultivate a Ubiquitous Language
      4. Refactoring Tactical Design Decisions
    3. Pragmatic Domain-Driven Design
    4. Selling Domain-Driven Design
      1. Undercover Domain-Driven Design
    5. Conclusion
    6. Exercises
  20. IV. Relationships to Other Methodologies and Patterns
  21. 14. Microservices
    1. What Is a Service?
    2. What Is a Microservice?
      1. Method as a Service: Perfect Microservices?
      2. Design Goal
      3. System Complexity
      4. Microservices as Deep Services
      5. Microservices as Deep Modules
    3. Domain-Driven Design and Microservices’ Boundaries
      1. Bounded Contexts
      2. Aggregates
      3. Subdomains
    4. Compressing Microservices’ Public Interfaces
      1. Open-Host Service
      2. Anticorruption Layer
    5. Conclusion
    6. Exercises
  22. 15. Event-Driven Architecture
    1. Event-Driven Architecture
      1. Scope
    2. Events
      1. Events, Commands, and Messages
      2. Structure
      3. Types of Events
    3. Designing Event-Driven Integration
      1. Distributed Big Ball of Mud
      2. Temporal Coupling
      3. Logical Coupling
      4. Implementation Coupling
      5. Refactoring the Event-Driven Integration
      6. Event-Driven Design Heuristics
    4. Conclusion
    5. Exercises
  23. 16. Data Mesh
    1. Analytical Data Model Versus Transactional Data Model
      1. Fact Table
      2. Dimension Table
      3. Analytical Models
    2. Analytical Data Management Platforms
      1. Data Warehouse
      2. Data Lake
      3. Challenges of Data Warehouse and Data Lake Architectures
    3. Data Mesh
      1. Decompose Data Around Domains
      2. Data as a Product
      3. Enable Autonomy
      4. Build an Ecosystem
      5. Combining Data Mesh and Domain-Driven Design
    4. Conclusion
    5. Exercises
  24. Closing Words
    1. Problem
    2. Solution
    3. Implementation
    4. Further Reading
      1. Advanced Domain-Driven Design
      2. Architectural and Integration Patterns
      3. Modernization of Legacy Systems
      4. Event Storming
    5. Conclusion
  25. A. Applying DDD: A Case Study
    1. Five Bounded Contexts
      1. Business Domain
      2. Bounded Context #1: Marketing
      3. Bounded Context #2: Customer Relationship Management (CRM)
      4. Bounded Context #3: Event Crunchers
      5. Bounded Context #4: Bonuses
      6. Bounded Context #5: The Marketing Hub
    2. Discussion
      1. Ubiquitous Language
      2. Subdomains
      3. Boundaries of Bounded Contexts
    3. Conclusion
  26. B. Answers to Exercise Questions
    1. Chapter 1
    2. Chapter 2
    3. Chapter 3
    4. Chapter 4
    5. Chapter 5
    6. Chapter 6
    7. Chapter 7
    8. Chapter 8
    9. Chapter 9
    10. Chapter 10
    11. Chapter 11
    12. Chapter 12
    13. Chapter 13
    14. Chapter 14
    15. Chapter 15
    16. Chapter 16
  27. References
  28. Index

Product information

  • Title: Learning Domain-Driven Design
  • Author(s): Vlad Khononov
  • Release date: October 2021
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781098100131