Skip to content

Repository files navigation

Illegal States

Code for a lightning talk on making illegal states unrepresentable in C# and F#.

The code follows Scott Wlashin's excellent Designing with types blog series.

There are tests for each language, but these don't assert that the code is correct, they just show the shape of the data in the console:

img.png

How to follow

Start at the main branch, then follow the branches by number.

Main

This is the starting point. It shows a naive implementation of a contact type and how that's not safe.

publicrecordContact{publicstringFirstName{get;init;}="";publicstringMiddleInitial{get;init;}="";publicstringLastName{get;init;}="";publicstringEmailAddress{get;init;}="";publicboolIsEmailVerified{get;init;}publicstringAddress1{get;init;}="";publicstringAddress2{get;init;}="";publicstringCity{get;init;}="";publicstringState{get;init;}="";publicstringZip{get;init;}="";publicboolIsAddressValid{get;init;}}

Links

Bonus Ball

Scott Wlashin's series is really about domain modelling. The last section of the series presents a more meaningful challenge:

“A contact must have at least one of the following: an email, a postal address, a home phone, or a work phone”_

https://fsharpforfunandprofit.com/posts/designing-with-types-discovering-the-domain/

His book is excellent too!

https://fsharpforfunandprofit.com/books/

About

Code for a lighting talk based on Scott Wlashin's domain modelling principles.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages