Skip to content

Instantly share code, notes, and snippets.

@jdh30 jdh30/CleanerCode.fs
Created Jan 28, 2017

What would you like to do?
type AccountKind = Simple | Valuable | MostValuable
type CustomerStatus =
| Unregistered
| Registered of AccountKind * Years:int
let accountFactor kind =
match kind with
| Simple -> 0.9m
| Valuable -> 0.7m
| MostValuable -> 0.5m
let loyaltyFactor years =
1m - decimal(min years 5) / 100m
let applyDiscount price status =
match status with
| Unregistered -> price
| Registered(kind, years) ->
price * accountFactor kind * loyaltyFactor years

This comment has been minimized.

Copy link

mdpopescu commented Nov 6, 2017

Great job with the refactoring. Seeing examples like this make me want to look into F#... but then I see this and it drives me nuts:

Registered of AccountKind * Years:int

I am really curious about the thought process of whoever came up with that, instead of the much more obvious

Registered: AccountKind, Years: int


Registered of AccountKind, Years of int

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.