small medium large xlarge

Domain Modeling Made Functional: Tackle Software Complexity with Domain-Driven Design and F#


Cover image for Domain Modeling Made Functional

Domain Modeling Made Functional

Tackle Software Complexity with Domain-Driven Design and F#


You want increased customer satisfaction, faster development cycles, and less wasted work. Domain-driven design (DDD) combined with functional programming is the innovative combo that will get you there. In this pragmatic, down-to-earth guide, you’ll see how applying the core principles of functional programming can result in software designs that model real-world requirements both elegantly and concisely—often more so than an object-oriented approach. Practical examples in the open-source F# functional language, and examples from familiar business domains, show you how to apply these techniques to build software that is business-focused, flexible, and high quality.

Customer Reviews

Scott Wlaschin is one of the most important communicators in practical, applied programming today. In this book, he brings clarity and simplicity to the process of bridging the gap between requirements, customers, and concrete designs and code. Enjoy!

- Don Syme

Researcher, Microsoft U.K.

A few years ago, Scott’s blog was my first encounter with domain modeling in a functional language—and it’s still my favorite. He has a knack for expressing abstract topics in a clear and approachable way.

- Mathias Verraes

Domain-Driven Design Europe

This is a fantastic book that takes you through the process of making software from start to finish, both on a technical and a functional level. I loved reading it!

- Gien Verschatse

Owner, Eight Point Squared

Domain Modeling Made Functional is easy to read and engaging—but it doesn’t miss a beat for technical thoroughness or depth. I highly recommend this book as an introduction to both functional programming and domain-driven design.

- Chris Krycho

Senior Software Engineer, Olo

This book crystallizes Domain-Driven Design in a refreshingly pragmatic way. The author’s ability to present key ideas by example rather than theory make this a must-read for any developer interested in DDD.

- Devon Burriss

Technical Pathfinder, Coolblue B.V.

See All Reviews

Choose Your Format(s)

  • $47.95 In Stock

    Save $14.95 on the combo pack.

  • $37.95 In Stock
  • $24.95 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

What You Need

The code in this book is designed to be run interactively on Windows, Mac and Linux. You will need a recent version of F# (4.0 or greater), and the appropriate .NET runtime for your platform. Full installation instructions for all platforms at

Contents & Extracts

  • Preface
  • Understanding the Domain*
    • Introducing Domain-Driven Design
      • The Importance of a Shared Model
      • Understanding the Domain Through Business Events
      • Partitioning the Domain into Subdomains
      • Creating a Solution Using Bounded Contexts
      • Creating a Ubiquitous Language
      • Summarizing the Concepts of Domain-Driven Design
      • Wrapping Up
    • Understanding the Domain
      • Interview with a Domain Expert
      • Fighting the Impulse to Do Database-Driven Design excerpt
      • Fighting the Impulse to Do Class-Driven Design
      • Documenting the Domain
      • Diving Deeper into the Order-Taking Workflow
      • Representing Complexity in Our Domain Model
      • Wrapping Up
    • A Functional Architecture
      • Bounded Contexts as Autonomous Software Components
      • Communicating Between Bounded Contexts
      • Contracts Between Bounded Contexts
      • Workflows Within a Bounded Context
      • Code Structure Within a Bounded Context
      • Wrapping Up
      • What’s Next
  • Modeling the Domain
    • Understanding Types
      • Understanding Functions
      • Types and Functions
      • Composition of Types
      • Working with F# Types
      • Building a Domain Model by Composing Types
      • Modeling Optional Values, Errors, and Collections
      • Organizing Types in Files and Projects
      • Wrapping Up
    • Domain Modeling with Types
      • Reviewing the Domain Model
      • Seeing Patterns in a Domain Model
      • Modeling Simple Values
      • Modeling Complex Data excerpt
      • Modeling Workflows with Functions
      • A Question of Identity: Value Objects
      • A Question of Identity: Entities
      • Aggregates
      • Putting It All Together
      • Wrapping Up
    • Integrity and Consistency in the Domain
      • The Integrity of Simple Values
      • Units of Measure
      • Enforcing Invariants with the Type System
      • Capturing Business Rules in the Type System
      • Consistency
      • Wrapping Up
    • Modeling Workflows as Pipelines
      • The Workflow Input
      • Modeling an Order as a Set of States
      • State Machines
      • Modeling Each Step in the Workflow with Types
      • Documenting Effects
      • Composing the Workflow from the Steps
      • Are Dependencies Part of the Design?
      • The Complete Pipeline
      • Long-Running Workflows
      • Wrapping Up
      • What’s Next
  • Implementing the Model
    • Understanding Functions
      • Functions, Functions, Everywhere
      • Functions Are Things excerpt
      • Total Functions
      • Composition
      • Wrapping Up
    • Implementation: Composing a Pipeline
      • Working with Simple Types
      • Using Function Types to Guide the Implementation
      • Implementing the Validation Step
      • Implementing the Rest of the Steps
      • Composing the Pipeline Steps Together
      • Injecting Dependencies
      • Testing Dependencies
      • The Assembled Pipeline
      • Wrapping Up
    • Implementation: Working with Errors
      • Using the Result Type to Make Errors Explicit
      • Working with Domain Errors
      • Chaining Result-Generating Functions
      • Using bind and map in Our Pipeline
      • Adapting Other Kinds of Functions to the Two-Track Model
      • Making Life Easier with Computation Expressions
      • Monads and More
      • Adding the Async Effect
      • Wrapping Up
    • Serialization
      • Persistence vs. Serialization
      • Designing for Serialization
      • Connecting the Serialization Code to the Workflow
      • A Complete Serialization Example
      • How to Translate Domain Types to DTOs
      • Wrapping Up
    • Persistence
      • Pushing Persistence to the Edges
      • Command-Query Separation
      • Bounded Contexts Must Own Their Data Storage
      • Working with Document Databases
      • Working with Relational Databases
      • Transactions
      • Wrapping Up
    • Evolving a Design and Keeping It Clean
      • Change 1: Adding Shipping Charges
      • Change 2: Adding Support for VIP Customers
      • Change 3: Adding Support for Promotion Codes
      • Change 4: Adding a Business Hours Constraint
      • Dealing with Additional Requirements Changes
      • Wrapping Up
      • Wrapping Up the Book


Scott Wlaschin is an expert on F#, author of the popular F# site, and a board member of the F# Software Foundation. Known for his non-academic approach to functional programming, Scott is a popular speaker and has given talks at NDC, F# Exchange, DDD Europe, and other conferences around the world.

Upcoming Author Events