SlideShare a Scribd company logo
Cameron Presley
@pcameronpresley
Cameron@TheSoftwareMentor.com
How
Functional Programming
Made Me
a Better Developer
2
Hello!
3
4
“
The single responsibility principle states
that every module or class should have
responsibility over a single part of
the functionality provided by
the software, and that responsibility
should be entirely encapsulated by the
class.
-Wikipedia
5
“
The single responsibility principle states
that every module or class should have
responsibility over a single part of
the functionality provided by
the software, and that responsibility
should be entirely encapsulated by the
class.
-Wikipedia
6
What Happens
If You Follow SRP
to the Extreme?
7
8
9
10
11
http://blog.ploeh.dk/2014/03/10/solid-the-next-step-is-functional/
Extreme SRP and ISP
=
lots of fine grain classes
12
Objects can be thought of data
with behavior, but what if we
flipped that around?
13
14
F#
15
16
Task Snapper
○ C# application that grabs a
screenshot every so often
○ Focus on the language, not the
problem
17
18
19
20
21
22
23
Love Letter
○ 8 different kinds of cards, each with
their own rules
○ Write more idiomatic fp
○ No classes or exceptions
24
25
26
27
28
29
30
Blackjack!
○ Still modeling a card game
○ Something with easier business rules
○ Already knew the rules
31
32
33
How would you score a hand in
Blackjack?
Figure out how many Points
each Card is worth
Add the Points up
34
35
36
37
38
39
40
different outputs
the same output
A method, that when given the
same two inputs, it returns…
41
Methods that always return
output solely based on input
are known to be pure
42
Sound crazy?
Elm
React with Redux
43
44
45
46
47
48
49
50
51
52
53
Interfaces are powerful because
they enforce a contract at the code
level.
If the contract isn’t observed,
the code won’t compile!
Given this interface, what should GetById return?
Pop Quiz!
Anything that implements this interface will always
return an Employee object, right?
55
56
57
What Happened?
Interface said that an Employee
will always be returned
But sometimes, there won’t be an
Employee, so what to return?
Compiler can’t enforce that I
handle null / exceptions
58
59
60
61
62
Boundary (data in/out)
Business Rules (processing the data)
Workflow (combination of both)
Boundary
○ Databases, files, APIs
○ Typically impure
○ For easier testing of workflows,
recommend using an interface
○ Inspiration from Alistair Cockburn’s
Hexagonal Architecture
63
64
65
Business Rules
○ Bulk of the application
○ Purity is key
○ Remember SOLID when implementing
66
67
Workflows
○ Combines both Boundary and Business Rule
○ General shape is:
○ Data comes in through the boundary
○ Data is processed by the business rules
○ Data goes out through the boundary
68
69
70
71
72
73
74
75
References
F#
• F Sharp for Fun and Profit (https://fsharpforfunandprofit.com)
• The Book of F#: Breaking Free with Managed Functional Programming by Dave
Fancher
• F# Jumpstart (Pluralsight Course) by Kit Eason
Functional
• Mark Seemann’s blog: (http://blog.ploeh.dk)
• Hexagonal Architecture (post) by Alistair Cockburn
• Reid Evans YouTube
(https://www.youtube.com/channel/UCMxR2KmDlDMEsvfKOjzRNbA)
Code
• CRUDy : https://github.com/cameronpresley/CRUDy
• Optionally: https://github.com/cameronpresley/Optionally
Feedback!
76
http://blog.TheSoftwareMentor.com/F
eedback

More Related Content

PPTX
Automated Testing with Logic Apps and Specflow
PPTX
Testing for Logic App Solutions | Integration Monday
PDF
YAGNI Principle and Clean Code
ODP
I Smell A RAT- Rapid Application Testing
PDF
Dark side of JS development framework
PPTX
React Native: Expectations vs Reality
PPTX
How to Have Code Reviews That Developers Actually Want
PPTX
Resource Leaks in Java
Automated Testing with Logic Apps and Specflow
Testing for Logic App Solutions | Integration Monday
YAGNI Principle and Clean Code
I Smell A RAT- Rapid Application Testing
Dark side of JS development framework
React Native: Expectations vs Reality
How to Have Code Reviews That Developers Actually Want
Resource Leaks in Java

What's hot (20)

PPTX
OSS Java Analysis - What You Might Be Missing
PPTX
Humans by the hundred
PPTX
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
PPTX
Becoming fully buzzword compliant
PDF
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
PPTX
Is Groovy better for testing than Java?
PDF
Code Review Matters and Manners
PPTX
Defensive programming in php... by example
PDF
Level Up Your Automated Tests
PPTX
Level Up Your Automated Tests
PPTX
Concurrency Errors in Java
PDF
WE are Doing it Wrong - Dmitry Sharkov
PPTX
iHale Milestone 1 Feedback
PDF
Clean Software Design: The Practices to Make The Design Simple
PPTX
Sustainable Automation Frameworks by Kelsey Shannahan
PDF
Unwritten Manual for Pair Programming
PPTX
Behavior Driven Development - TdT@Cluj #15
PPTX
Finding Defects in C#: Coverity vs. FxCop
ODP
Legacycode01
PPTX
Adopting Agile
OSS Java Analysis - What You Might Be Missing
Humans by the hundred
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Becoming fully buzzword compliant
10 Faulty Behaviors of Code Review - Developer Summit Istanbul 2018
Is Groovy better for testing than Java?
Code Review Matters and Manners
Defensive programming in php... by example
Level Up Your Automated Tests
Level Up Your Automated Tests
Concurrency Errors in Java
WE are Doing it Wrong - Dmitry Sharkov
iHale Milestone 1 Feedback
Clean Software Design: The Practices to Make The Design Simple
Sustainable Automation Frameworks by Kelsey Shannahan
Unwritten Manual for Pair Programming
Behavior Driven Development - TdT@Cluj #15
Finding Defects in C#: Coverity vs. FxCop
Legacycode01
Adopting Agile
Ad

Similar to How Functional Programming Made Me a Better Developer (20)

PPTX
How Functional Programming Made Me A Better Developer
PDF
Reinventing the Transaction Script (NDC London 2020)
PPTX
Functional programming
PPTX
Cleaner Code - CodeStock 2019 Edition
PDF
2012 the clean architecture by Uncle bob
PPTX
Combating software entropy 2-roc1-
PPTX
Establishing a SOLID Foundation
PPTX
Cleaner Code: How Clean Code is Functional Code
PPTX
C:\Fakepath\Combating Software Entropy 2
PPTX
C:\Fakepath\Combating Software Entropy 2
PDF
Functional Programming in C#: How to write better C# code 1st Edition Enrico ...
PPTX
Introduction to Functional Programming
ODP
Functional programming
PDF
Introduction to functional programming
PPTX
Why functional programming in C# & F#
PDF
Functional Programming Patterns (BuildStuff '14)
PPTX
Functional Programming
PPTX
Functional DDD
PPTX
TechDaysNL 2015 - F# for C# Developers
PPTX
Iterative architecture
How Functional Programming Made Me A Better Developer
Reinventing the Transaction Script (NDC London 2020)
Functional programming
Cleaner Code - CodeStock 2019 Edition
2012 the clean architecture by Uncle bob
Combating software entropy 2-roc1-
Establishing a SOLID Foundation
Cleaner Code: How Clean Code is Functional Code
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
Functional Programming in C#: How to write better C# code 1st Edition Enrico ...
Introduction to Functional Programming
Functional programming
Introduction to functional programming
Why functional programming in C# & F#
Functional Programming Patterns (BuildStuff '14)
Functional Programming
Functional DDD
TechDaysNL 2015 - F# for C# Developers
Iterative architecture
Ad

More from Cameron Presley (7)

PPTX
The Engineer's Playbook: Starting a New Role
PPTX
Taking a Gamble with Functional Domain Modeling
PPTX
Level Up Your Functional Programming Skills with LINQ
PPTX
Functional Programming Through Construction : First Principles
PPTX
Making the Unstable Stable - An Intro To Testing
PPTX
Indy Code - Taking a Gamble With F#: Implementing Blackjack
PPTX
Establishing a SOLID Foundation - An Intro to Software Design
The Engineer's Playbook: Starting a New Role
Taking a Gamble with Functional Domain Modeling
Level Up Your Functional Programming Skills with LINQ
Functional Programming Through Construction : First Principles
Making the Unstable Stable - An Intro To Testing
Indy Code - Taking a Gamble With F#: Implementing Blackjack
Establishing a SOLID Foundation - An Intro to Software Design

Recently uploaded (20)

PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation theory and applications.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Machine learning based COVID-19 study performance prediction
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
Electronic commerce courselecture one. Pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
20250228 LYD VKU AI Blended-Learning.pptx
The AUB Centre for AI in Media Proposal.docx
Programs and apps: productivity, graphics, security and other tools
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Cloud computing and distributed systems.
Encapsulation theory and applications.pdf
sap open course for s4hana steps from ECC to s4
Machine learning based COVID-19 study performance prediction
MIND Revenue Release Quarter 2 2025 Press Release
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Unlocking AI with Model Context Protocol (MCP)
“AI and Expert System Decision Support & Business Intelligence Systems”
Building Integrated photovoltaic BIPV_UPV.pdf
Machine Learning_overview_presentation.pptx
Electronic commerce courselecture one. Pdf

How Functional Programming Made Me a Better Developer

Editor's Notes

  • #4: The Road Taken Learning Functional Programming (i.e. What Got Me Started Down This Path?)
  • #5: Some SOLID Inspiration SOLID = Mnemonic for software designed By following SOLID we tend to write more maintainable software Want to focus on S (Single Responsibility Principle)
  • #9: Lot of small classes with a single public method A lot of ceremony Could use ReSharper or another tool to create the boilerplate, but how about eliminate the need for it?
  • #10: Asking the Twitterverse for help
  • #12: Like most things in software development, I wasn’t the first to come to this
  • #15: Chose F# Familiar with .NET Comfortable with the tooling Community resources
  • #16: I worked on/off with functional for a year Lots of heads down, then come up for air for a bit Rinse and repeat Took three attempts for me to really “get” it
  • #17: First Attempt!
  • #18: Decided to port a C# application (Task Snapper) Grabs a screenshot every so often Idea was to focus on the language, not how to solve the problem
  • #19: Defined a type Attached functions to it Some of those functions threw exceptions
  • #20: Defined a type Attached functions to it Some of those functions threw exceptions
  • #21: Defined a type Attached functions to it Some of those functions threw exceptions
  • #22: Defined a type Attached functions to it Some of those functions threw exceptions
  • #23: I wrote F# But wrote OO in FP Didn’t really see the point Need to learn more about FP
  • #26: Look ma, no exceptions! Learned more about data modeling (making illegal states unrepresentable) Game rules a bit more complicated than expected *Spent a lot of time learning the problem and attempting a solution, not porting
  • #27: Modeling Data and State using Discriminated Unions
  • #28: Using type aliases
  • #29: Making new types out of existing types using records
  • #30: No classes, no exceptions!
  • #31: 3rd Attempt
  • #33: Making Illegal States Unrepresentable
  • #35: Modeling how to turn a Card into a
  • #36: How to add two points together
  • #38: Reflection * Comfortable with handling errors without exceptions Using pattern matching more effectively Working with built-in List operators Map and Reduce Starting to think about how to use these concepts in C#
  • #39: Learned all of this cool stuff, how does it affect my coding habits now?
  • #40: Code is easy to test implies code is easy to maintain The opposite may hold then, hard to test code may not be maintainable What defines easy to test code?
  • #41: What’s easier to test? Which method would be easier to troubleshoot?
  • #42: Implies there are no side effects (databases, file systems, apis, etc…) Easiest thing to test because no dependencies are needed
  • #43: Elm Architecture (time traveling debugger) React with Redux (reducers)
  • #44: Pure because 3 will always return the same value
  • #45: Not pure because the API could fail or give me back different values
  • #46: Improved LINQ Skills
  • #47: When working with lists of data, here’s how I’d used to do it Quickly, what am I trying to do here?
  • #50: Before and after The one on the left, I have to keep track of what I’m doing The one on the right, I can trust that LINQ works and I’m plugging my business rules into the correct places
  • #51: Designing Interfaces that don’t suck
  • #54: Allows us to lean on the compiler
  • #60: Why doesn’t this work? Options have no clue about Id, FirstName or LastName
  • #61: Pattern match to figure out what to do. Compiler forced us to do that! Win!
  • #62: How I build software
  • #65: Getting data into the system
  • #66: Getting data out of the system
  • #75: Learning functional was hard for me Lots of failures, but improved incrementally Made me re-evaluate how I build software Still use functional concepts in my coding Even if I’m not using a functional language