Skip to content

Instantly share code, notes, and snippets.

@swlaschin
Last active November 11, 2023 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save swlaschin/c7a3f258cdb9fd7d5cf72cbaad3d6e1d to your computer and use it in GitHub Desktop.
Save swlaschin/c7a3f258cdb9fd7d5cf72cbaad3d6e1d to your computer and use it in GitHub Desktop.
Workshop outline: "Domain Modeling Made Functional"

Workshop: Domain Modeling Made Functional

Functional programming and domain-driven design might not seem to be a good match, but in fact functional programming can be an excellent approach to designing decoupled, reusable systems with a rich domain model. This workshop will show you why.

This will be a hands-on workshop designed for beginners in functional programming. We'll do lots of exercises and build some small projects that take us all the way from high-level design to low-level implementation.

Who is this for?

This will be especially useful for people learning functional programming -- all concepts used in the workshop will be explained. Previous development experience is recommended.

What you'll learn

  • The concepts of functional programming
  • How to represent the nouns and verbs of a domain using types and functions
  • How to decouple the pure domain logic from the outside world
  • How to ensure that constraints and business rules are captured in the design
  • How to represent state transitions in the domain model
  • How to build a business workflow from smaller components
  • How to handle errors as part of the domain

By the end of the workshop you'll know how to build working solutions with rich domain models, using only functional programming techniques.

Program

  • Overview of DDD principles
    • Building a shared model and representing it in code
    • Persistence ignorance
    • Domain modelling with AND/OR
  • Introduction to functional programming
    • Functions and types
    • Composition as the fundamental principle
  • Domain Modeling with algebraic types
    • Records, choices, simple types, and functions
    • Modeling constraints, options
    • Making illegal states unrepresentable
    • Modeling states
  • Error handling
    • Handling domain errors
    • Railway oriented programming
    • Composing error generating functions with bind (monads!)
    • Validation
  • Functional architecture
    • Keeping IO at the edges
    • DTOs versus Domain objects and how to transform between them.
  • Programming a complete workflow
    • Putting it all together

Prerequisites

We will be using F# as our development language. No experience with F# needed. Please install the F# compiler and an F#-friendly editor such as Visual Studio Code using the instructions at fsharp.org or http://ionide.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment