Presentation for Functional Domain Modeling where I cover how to identify/implement the domain for Blackjack. From there, we take a look at implementing various workflows by exploring the Maybe type!
6. @pcameronpresley
Overview
Game played with a standard deck of cards
Objective is to get closest to 21 points
without going over
Involves one or more players playing against
the dealer
6
7. @pcameronpresley
Set Up
Each player is dealt two cards face-up to
form their hand
Dealer is dealt two cards (one face-up) to
form their hand
7
8. @pcameronpresley
Game Play
On their turn, a player can take an action
Once all players have taken their turn, dealer
takes their turn
After dealer completes their turn, each
player compares their hand with the dealer
8
9. @pcameronpresley
Player Turn
Players can either “Hit” or “Stand”
◦ Stand – Ends the turn, staying in
◦ Hit – Draw a card
If their hand goes over 21, they “bust”
ending their turn and leaving the round
9
10. @pcameronpresley
Scoring
Aces can be worth 1 or 11 points
Face cards are worth 10 points
Number cards are worth that many points
If a player or dealer is dealt a hand worth 21
points (an Ace and a 10 point card), they
have a Blackjack, winning automatically
10
13. @pcameronpresley
What are the nouns?
Game played with a standard deck of cards
Objective is to get closest to 21 points
without going over
Involves one or more players playing against
the dealer
13
17. @pcameronpresley
On their turn, a player can take an action
Once all players have taken their turn, dealer
takes their turn
After dealer completes their turn, each
player compares their hand with the dealer
17
19. @pcameronpresley
Players can either “Hit” or “Stand”
◦ Stand – Ends the turn, staying in
◦ Hit – Draw a card
If their hand goes over 21, they “bust”
ending their turn and leaving the round
19
29. @pcameronpresley
Introducing The Sum Type!
Type that can be one of a finite number of
choices
Each choice is a different constructor
When a type can be A or B or C
29
36. @pcameronpresley
Introducing the Product Type!
Type that specifies the combination of other
types
It’s the product of the possible values for all
types it combines
36
79. @pcameronpresley
79
By using Option, we’re signaling that this function may return
a value and that callers will need to deal with the absence of
value
85. @pcameronpresley
What Did We Cover?
Introduction to Blackjack
Defining the Domain
Implementing the Domain
Implementing common workflows
85
87. @pcameronpresley
Resources
◦ Thinking Functionally (series) by Scott Wlaschin
◦ Functional Architecture : a definition by Mark Seemann
◦ Functional Architecture Is Ports and Adapters by Mark Seemann
◦ Algebraic Data Types Aren't Numbers on Steroids by Mark
Seemann
◦ Domain Modeling Made Functional by Scott Wlaschin