Lesson 23. Business rules as code

In this last lesson of the unit, you’ll see how to use F# language features such as records, options, and discriminated unions to write code that can enforce business rules within code. This lesson covers the following:

  • Conventional ways to validate business rules
  • Exploring domain modeling in F# more closely
  • Exploring single-case discriminated unions
  • Encoding business rules through types
  • Exception handling

Our code always has some form of business rules within it. Generally, we validate that our code is correct either by running the application and manually seeing whether it does the right thing, or by writing some form of automated test suite that sits alongside our code. This test suite often is as large ...

Get Get Programming with F# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.