[Functional Programming] Domain Modeling Made Functional (Pragprog) (F#)

by Scott Wlaschin

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.


Domain-driven design is a well-established approach to designing software that ensures that domain experts and developers work together effectively to create high-quality software. This book is the first to combine DDD with techniques from statically typed functional programming. This book is perfect for newcomers to DDD or functional programming—all the techniques you need will be introduced and explained.

Model a complex domain accurately using the F# type system, creating compilable code that is also readable documentation—ensuring that the code and design never get out of sync. Encode business rules in the design so that you have “compile-time unit tests,” and eliminate many potential bugs by making illegal states unrepresentable. Assemble a series of small, testable functions into a complete use case, and compose these individual scenarios into a large-scale design. Discover why the combination of functional programming and DDD leads naturally to service-oriented and hexagonal architectures. Finally, create a functional domain model that works with traditional databases, NoSQL, and event stores, and safely expose your domain via a website or API.

Solve real problems by focusing on real-world requirements for your software.

Don’t forget you can get 35% off the ebook with your forum discount, use code ‘ElixirForum’ :023:

https://pragprog.com/book/swdddf/domain-modeling-made-functional

9 Likes

I’ve split your post into a new thread :023:

Though not sure it belongs in the Elixir related sections (or to go in General Programming) - have you read the book? Does the content relate to Elixir in any meaningful way?

2 Likes

Scott Wlaschin’s talk’s on how to think functionally are excellent, so it’s a matter of not letting the vehicle (F#) getting in the way of accessing good information (F# is essentially .NET’s version of OCaml). So it’s about “functional programming” rather than “Elixir”.

5 Likes

His talks on youtube are excellent! Thanks for that name.

1 Like

Not read yet, it is on my to read list :). I only heard podcast with him. Link added.
This is not related to Elixir directly, rather general programming / design.
He is also owner of https://fsharpforfunandprofit.com/

1 Like

The intention is for all pragprog books to eventually graduate from ebooks to having a printed version? is that the case? Looks really interesting but will wait for the finished version

I have been reading this, and have picked up some v nice tidbits. Not the greatest book ever, but there are some nuggets to be gleaned.

beta 3 version is out now

1 Like

Thinking of getting this book - anyone else got some reviews? Particularly on whether or not its got some really good take aways that can properly help me improve my design + architecture of my code?

1 Like

I am half way through (still).

There is a bunch of practical things to learn.

Examples are in F# but applicable to any ML style language imo (perhaps more broadly also)

1 Like

Scott Wlaschin: F# for C# programmers [NDC Oslo June 12, 2017]

Likely a good resource to recommend for anybody looking for arguments to “go functional” in the .Net space.

His discussion of types vs classes is generally interesting.

2 Likes

It’s very clearly written. He goes through an entire Domain Driven design process, from white-boarding to code. The preview pages can give you a good idea of how it is.

I’ve studied F# for a number of years, and am thinking of how to apply this book to ReasonML and perhaps Fable. I was especially interested in his discussions on making illegal states un-representable - sort of a way of encoding business logic into the type system itself.

2 Likes

Scott Wlaschin: Domain Modeling Made Functional [NDC Sydney August 14-18, 2017]

3 Likes

Thanks a lot ^-^

Count this discount also for the printed version?

P.S: Two comments at Goodreads suggests that it is very applicable to other functional languages. https://www.goodreads.com/book/show/34921689-domain-modeling-made-functional

The PragProg forum discounts are for ebooks only :slight_smile:

1 Like

Thanks a lot.

Thirteen ways of looking at a Turtle - Scott Wlaschin
Starts with an API for turtle graphics and then compares 13 different implementation styles:

  1. Object Oriented Turtle
  2. Abstract Data Turtle
  3. Functional Turtle
  4. State Monad
  5. Error Handling
    5.5 Async Turtle
  6. Batch Commands
  7. Actor model
  8. Event Sourcing
  9. Stream Processing
  10. OO style dependency injection
  11. FP style dependency injection
  12. Interpreter
  13. Capabilities
3 Likes

Designing with Capabilities - Scott Wlaschin

Spoiler: Capabilities are a generalization of HatEoAS (Hypermedia as the Engine of Application State) concept from REST (where the links inside a resource are a manifestation of what you are capable of doing next) in the service of making “illegal operations unavailable”.