SlideShare a Scribd company logo
TechDaysNL 2015 - DDD with F#
DDD with F#
Ronald Harmsen
"Focus on the domain and
domain logic rather than
technology”
Eric Evans
DDD F#
Why?
TechDaysNL 2015 - DDD with F#
“First, it’s almost certainly true that functional programming
is the next big thing. “
Robert C. Martin
“Object oriented programming makes code understandable
by encapsulating moving parts. Functional programming makes
code understandable by minimizing moving parts.“
Michael Feathers
“F# is excellent at concisely expressing business and domain logic.
Developers trying to achieve explicit business logic within an
Application may opt to express their domain in F# with the
majority of plumbing code in C#.”
Functional programming
• Declarative
• Clearity
• Composability
• Immutability
Characteristic Imperative approach Functional approach
Programmer focus
How to perform tasks (algorithms)
how to track changes in state.
What information is desired and what
transformations are required.
State changes Important. Non-existent.
Order of execution Important. Low importance.
Primary flow control
Loops, conditionals, and function
(method) calls.
Function calls, including recursion.
Primary manipulation
unit
Instances of structures or classes.
Functions as first-class objects
data collections.
Characteristic C# F#
Programmer focus
How to perform tasks (algorithms)
how to track changes in state.
What information is desired and what
transformations are required.
State changes Important. Non-existent.
Order of execution Important. Low importance.
Primary flow control
Loops, conditionals, and function
(method) calls.
Function calls, including recursion.
Primary manipulation
unit
Instances of structures or classes.
Functions as first-class objects
data collections.
Why F# ?
• Functional-first
• Very strong type inference
• Integrate with other .NET technologies
• Windows, Web, Xamarin iOS & Android, Linux
The functional language in .NET
DDD
But first a small introduction to functions in F#
Functions
Everything is a function
let a = 10
int a () {
return 10;
}
let sum a b = a + b
int sum (int a, int b) {
return a + b;
}
Composability
Chaining
Chaining functions makes a service,
Chaining services makes an use-case
public static class Calc
{
public static decimal Square(decimal n)
{
return n * n;
}
public static decimal MultiplyByPi(decimal n)
{
return n*3.14m;
}
public static decimal AreaOfCicle(decimal r)
{
return MultiplyByPi(Square(r));
}
}
module Calc
let square n = n ** 2.0
let multiplyByPi n = n * 3.14
let areaOfCircle r =
multiplyByPi (square (r))
module Calc
let square n = n ** 2.0
let multiplyByPi n = n * 3.14
let areaOfCircle r =
r |> square |> multiplyByPi
DDD
It’s all about modelling types
Types
type Email = string
type SimplePerson = Name * Email
type AnotherPerson =
{ Name: string; Age: int }
public class AnotherPerson
{
public AnotherPerson(string name, int age)
{
Name = name;
Age = age;
}
public string Name { get; private set; }
public int Age { get; private set; }
public override int GetHashCode()
{
return Name.GetHashCode() + Age.GetHashCode();
}
public override bool Equals(object obj)
{
return Equals(obj as AnotherPerson);
}
public bool Equals(AnotherPerson other)
{
if (other == null)
return false;
return Name == other.Name && Age == other.Age;
}
}
module CardGameBoundedContext =
type Suit = Club | Diamond | Spade | Heart
type Rank = Two | Three | Four | Five | Six
| Seven | Eight | Nine | Ten
| Jack | Queen | King | Ace
type Card = Suit * Rank
type Hand = Card list
type Deck = Card list
type Player = {Name:string; Hand:Hand}
type Game = {Deck:Deck; Players: Player list}
type Deal = Deck -> (Deck * Card)
type PickupCard = (Hand * Card)-> Hand
module MoreTypes
type IPrintable =
abstract member Print : unit -> unit
type SomeClass () =
interface IPrintable
with
member this.Print () = printfn “Hello”
type AnotherClass (i: int) =
member this.Value = i
member val this.Mutable: int with get, set
Demo
Ronald Harmsen
ronald@nforza.nl
www.nforza.nl
@ronaldharmsen
Simple. Clear. Software.
Your feedback is important!
Scan the QR Code and let us know via the TechDays App.
Laat ons weten wat u van de sessie vindt!
Scan the QR Code via de TechDays App.
Bent u al lid van de Microsot Virtual Academy?! Op MVA kunt u altijd iets
nieuws leren over de laatste technologie van Microsoft. Meld u vandaag aan
op de MVA Stand. MVA biedt 7/24 gratis online training on-demand voor IT-
Professionals en Ontwikkelaars.
TechDaysNL 2015 - DDD with F#

More Related Content

PPT
Programming
PPTX
Mercury: A Functional Review
PPT
Intermediate code generation (Compiler Design)
PPT
Intermediate code generation
PPTX
Intermediate code
PPT
Code optimisation presnted
PPTX
COMPILER DESIGN AND CONSTRUCTION
PPTX
Lecture 12 intermediate code generation
Programming
Mercury: A Functional Review
Intermediate code generation (Compiler Design)
Intermediate code generation
Intermediate code
Code optimisation presnted
COMPILER DESIGN AND CONSTRUCTION
Lecture 12 intermediate code generation

What's hot (20)

PPTX
F# Eye 4 the C# Guy
PDF
Intermediate code generation
PPTX
Intermediate code generator
PPTX
Syntax-Directed Translation into Three Address Code
PPTX
Intermediate code generation1
PPTX
Basic Block
DOCX
Cs6660 compiler design may june 2017 answer key
PPTX
Dag representation of basic blocks
DOCX
Cs6660 compiler design november december 2016 Answer key
PPT
Interm codegen
PPTX
Dead Code Elimination
PPT
Iterative deepening search
PPT
Sdd Syntax Descriptions
PPTX
Back patching
PPT
Intermediate code generation
PDF
Database Management System-session 3-4-5
PPTX
Code optimization
PPTX
Principle source of optimazation
PPTX
Formal verification
PDF
F# Eye 4 the C# Guy
Intermediate code generation
Intermediate code generator
Syntax-Directed Translation into Three Address Code
Intermediate code generation1
Basic Block
Cs6660 compiler design may june 2017 answer key
Dag representation of basic blocks
Cs6660 compiler design november december 2016 Answer key
Interm codegen
Dead Code Elimination
Iterative deepening search
Sdd Syntax Descriptions
Back patching
Intermediate code generation
Database Management System-session 3-4-5
Code optimization
Principle source of optimazation
Formal verification
Ad

Similar to TechDaysNL 2015 - DDD with F# (20)

PPTX
TechDaysNL 2015 - F# for C# Developers
PPT
F# and the DLR
PDF
TI1220 Lecture 14: Domain-Specific Languages
PDF
Reinventing the Transaction Script (NDC London 2020)
PPTX
Creating Domain Specific Languages in F#
PPTX
Functional programming with FSharp
PDF
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
PPTX
F# for Trading
PDF
Building DSLs On CLR and DLR (Microsoft.NET)
PPTX
dinoC_ppt.pptx
PPTX
2 Years of Real World FP at REA
DOCX
Report on c and c++
PPT
Practices For Becoming A Better Programmer
PPT
Object Oriented Technologies
PPTX
.NET Foundation, Future of .NET and C#
PPT
Accessing loosely structured data from F# and C#
PPT
Visual Studio .NET2010
PDF
Map, flatmap and reduce are your new best friends (javaone, svcc)
PPTX
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
PDF
Functional Programming Patterns (BuildStuff '14)
TechDaysNL 2015 - F# for C# Developers
F# and the DLR
TI1220 Lecture 14: Domain-Specific Languages
Reinventing the Transaction Script (NDC London 2020)
Creating Domain Specific Languages in F#
Functional programming with FSharp
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
F# for Trading
Building DSLs On CLR and DLR (Microsoft.NET)
dinoC_ppt.pptx
2 Years of Real World FP at REA
Report on c and c++
Practices For Becoming A Better Programmer
Object Oriented Technologies
.NET Foundation, Future of .NET and C#
Accessing loosely structured data from F# and C#
Visual Studio .NET2010
Map, flatmap and reduce are your new best friends (javaone, svcc)
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
Functional Programming Patterns (BuildStuff '14)
Ad

Recently uploaded (20)

PPTX
Introduction to Artificial Intelligence
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Digital Strategies for Manufacturing Companies
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
System and Network Administration Chapter 2
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
medical staffing services at VALiNTRY
PDF
System and Network Administraation Chapter 3
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
history of c programming in notes for students .pptx
PPT
Introduction Database Management System for Course Database
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Nekopoi APK 2025 free lastest update
Introduction to Artificial Intelligence
wealthsignaloriginal-com-DS-text-... (1).pdf
How to Migrate SBCGlobal Email to Yahoo Easily
Computer Software and OS of computer science of grade 11.pptx
Softaken Excel to vCard Converter Software.pdf
Digital Strategies for Manufacturing Companies
Digital Systems & Binary Numbers (comprehensive )
2025 Textile ERP Trends: SAP, Odoo & Oracle
System and Network Administration Chapter 2
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PTS Company Brochure 2025 (1).pdf.......
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
medical staffing services at VALiNTRY
System and Network Administraation Chapter 3
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
history of c programming in notes for students .pptx
Introduction Database Management System for Course Database
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Nekopoi APK 2025 free lastest update

TechDaysNL 2015 - DDD with F#

  • 3. "Focus on the domain and domain logic rather than technology” Eric Evans
  • 7. “First, it’s almost certainly true that functional programming is the next big thing. “ Robert C. Martin
  • 8. “Object oriented programming makes code understandable by encapsulating moving parts. Functional programming makes code understandable by minimizing moving parts.“ Michael Feathers
  • 9. “F# is excellent at concisely expressing business and domain logic. Developers trying to achieve explicit business logic within an Application may opt to express their domain in F# with the majority of plumbing code in C#.”
  • 10. Functional programming • Declarative • Clearity • Composability • Immutability
  • 11. Characteristic Imperative approach Functional approach Programmer focus How to perform tasks (algorithms) how to track changes in state. What information is desired and what transformations are required. State changes Important. Non-existent. Order of execution Important. Low importance. Primary flow control Loops, conditionals, and function (method) calls. Function calls, including recursion. Primary manipulation unit Instances of structures or classes. Functions as first-class objects data collections.
  • 12. Characteristic C# F# Programmer focus How to perform tasks (algorithms) how to track changes in state. What information is desired and what transformations are required. State changes Important. Non-existent. Order of execution Important. Low importance. Primary flow control Loops, conditionals, and function (method) calls. Function calls, including recursion. Primary manipulation unit Instances of structures or classes. Functions as first-class objects data collections.
  • 13. Why F# ? • Functional-first • Very strong type inference • Integrate with other .NET technologies • Windows, Web, Xamarin iOS & Android, Linux The functional language in .NET
  • 14. DDD But first a small introduction to functions in F#
  • 16. let a = 10 int a () { return 10; }
  • 17. let sum a b = a + b int sum (int a, int b) { return a + b; }
  • 19. Chaining Chaining functions makes a service, Chaining services makes an use-case
  • 20. public static class Calc { public static decimal Square(decimal n) { return n * n; } public static decimal MultiplyByPi(decimal n) { return n*3.14m; } public static decimal AreaOfCicle(decimal r) { return MultiplyByPi(Square(r)); } }
  • 21. module Calc let square n = n ** 2.0 let multiplyByPi n = n * 3.14 let areaOfCircle r = multiplyByPi (square (r))
  • 22. module Calc let square n = n ** 2.0 let multiplyByPi n = n * 3.14 let areaOfCircle r = r |> square |> multiplyByPi
  • 23. DDD It’s all about modelling types
  • 24. Types type Email = string type SimplePerson = Name * Email type AnotherPerson = { Name: string; Age: int }
  • 25. public class AnotherPerson { public AnotherPerson(string name, int age) { Name = name; Age = age; } public string Name { get; private set; } public int Age { get; private set; } public override int GetHashCode() { return Name.GetHashCode() + Age.GetHashCode(); } public override bool Equals(object obj) { return Equals(obj as AnotherPerson); } public bool Equals(AnotherPerson other) { if (other == null) return false; return Name == other.Name && Age == other.Age; } }
  • 26. module CardGameBoundedContext = type Suit = Club | Diamond | Spade | Heart type Rank = Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queen | King | Ace type Card = Suit * Rank type Hand = Card list type Deck = Card list type Player = {Name:string; Hand:Hand} type Game = {Deck:Deck; Players: Player list} type Deal = Deck -> (Deck * Card) type PickupCard = (Hand * Card)-> Hand
  • 27. module MoreTypes type IPrintable = abstract member Print : unit -> unit type SomeClass () = interface IPrintable with member this.Print () = printfn “Hello” type AnotherClass (i: int) = member this.Value = i member val this.Mutable: int with get, set
  • 28. Demo
  • 30. Your feedback is important! Scan the QR Code and let us know via the TechDays App. Laat ons weten wat u van de sessie vindt! Scan the QR Code via de TechDays App. Bent u al lid van de Microsot Virtual Academy?! Op MVA kunt u altijd iets nieuws leren over de laatste technologie van Microsoft. Meld u vandaag aan op de MVA Stand. MVA biedt 7/24 gratis online training on-demand voor IT- Professionals en Ontwikkelaars.

Editor's Notes

  • #11: Functional is a form of declarative. C# imperative.
  • #14: WebSharper / FunScript -> JavaScript GPU programming /w Alea.cuBase
  • #20: WebSharper / FunScript -> JavaScript GPU programming /w Alea.cuBase