SlideShare a Scribd company logo
Functional SOLID
(Can I apply SOLID to FP?)
Alexandr Sugak,
Software Architect at Sigma Software,
https://github.com/AlexSugak
SOLID is about OOP
OR IS IT?
SOLID example
https://www.pluralsight.com/courses/encapsulation-solid
• Implement a message store;
• Messages are stored as files on disk;
• Messages are cached;
• Access to messages is logged.
SRP: one reason to change
• A module/class must encapsulate one thing;
• How to find this one thing?
• RCM’s answer: object must have one reason
for change.
SRP: file store
OCP: closed for modification
• Could it be that behavior of a class/module
may be extended/changed in future?
• How can we extract this reason for change as
an abstraction?
• How can we program that class/module once
and for all (close it)?
OCP: opened for extensibility
It is agreed that usually it is better to achieve
extensibility and reuse by composition instead of
inheritance.
https://en.wikipedia.org/wiki/Composition_over_inheritance
GoF:
“Ideally you shouldn’t have to create new components to achieve reuse. You should be
able to get all the functionality you need just by assembling existing components through
object composition. But this is rarely the case, because the set of available components is
never quite rich enough in practice. Reuse by inheritance makes it easier to make new
components that can be composed with old ones. Inheritance and object composition thus
work together.
Nevertheless, our experience is that designers overuse inheritance as a reuse technique
and designs are often made more reusable (and simpler) by depending more on object
composition. You’ll see object composition applied again and again in the design patterns.”
OCP: cache store via decorator
LSP: conforming to semantics of
an abstraction
What can we assume about implementation of
abstraction?
• Command Query Separation;
• Strong typing enforces semantics;
• Maybe<T> instead of nulls;
• Strongly typed errors;
• Code Contracts;
• Checked exceptions in Java;
• Etc.
LSP: store logger
ISP: do not depend on things you
do not use
• The smallest interface has one method;
• You cannot violate ISP if all interfaces have
one method.
ISP: message store
DIP: high must not depend on low
• Both must depend on abstraction;
• Programming against interfaces.
DIP: message store
SOLID Message Store:
decorators everywhere!
https://www.pluralsight.com/courses/encapsulation-solid
Extreme SOLID results in
• A bunch of one-method interfaces;
Extreme SOLID results in
• A bunch of one-method interfaces;
• A lot of small one/two-method classes;
Extreme SOLID results in
• A bunch of one-method interfaces;
• A lot of small one/two-method classes;
• Decorators everywhere;
Extreme SOLID results in
• A bunch of one-method interfaces;
• A lot of small one/two-method classes;
• Decorators everywhere;
• Compositions of complex behaviors out of
simple classes;
Extreme SOLID results in
• A bunch of one-method interfaces;
• A lot of small one/two-method classes;
• Decorators everywhere;
• Compositions of complex behaviors out of
simple classes;
• Other developers don’t like to work with such
code base.
Extreme SOLID results in
Extreme SOLID results in
Extreme SOLID results in doing
this:
https://github.com/AlexSugak/concurrencysample
To implement this:
https://github.com/AlexSugak/concurrencysample
Doing SOLID in OO requires
experience and discipline:
• Such code is not idiomatic to C# or Java;
• Our tools (IDE) are not optimized for this;
• Majority of developers are not used to this;
• Requires deep knowledge and understanding
in majority of the team.
SOLID in FP
OOP FP
One-method interfaces
One-method classes
Decorators
Composition
SOLID in FP
OOP FP
One-method interfaces Functions
One-method classes Functions
Decorators Functions
Composition Function composition
Message Store in F#, types:
https://github.com/AlexSugak/message-store
Message Store in F#, types:
Message Store in F#, types:
Partial Application of functions:
Partial Application of functions:
Pipe operator in F#:
Message Store in F#, file store:
Message Store in F#, store
cache:
Message Store in F#, store
logger:
Message Store in F#,
composition:
Message Store in F#,
composition:
Message Store in F#,
composition:
Message Store in F#, simpler:
http://www.fssnip.net/h4
SOLID in FP, simpler, easier:
• Coming up with a good abstraction is hard;
• PL should help with that, not make it more
difficult;
• FP focuses on types, function signatures,
composition, making it easier to reason about
abstractions;
• The result artifact is usually simpler.
Thank you!
Questions?
F# in Kharkiv:
https://www.facebook.com/groups/kharkivfsharp/

More Related Content

What's hot

PHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the codePHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the code
Michal Juhas
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvmdeimos
 
EclipseCon Europe 2016, S. Cela, M.Istria: Eclipse Generic and Extensible Edi...
EclipseCon Europe 2016, S. Cela, M.Istria: Eclipse Generic and Extensible Edi...EclipseCon Europe 2016, S. Cela, M.Istria: Eclipse Generic and Extensible Edi...
EclipseCon Europe 2016, S. Cela, M.Istria: Eclipse Generic and Extensible Edi...
Mickael Istria
 
[EclipseCon France 2017] Language Server Protocol in action
[EclipseCon France 2017] Language Server Protocol in action[EclipseCon France 2017] Language Server Protocol in action
[EclipseCon France 2017] Language Server Protocol in action
Mickael Istria
 
Java
JavaJava
Java
Vinayagam .D
 
Java- language Lecture 1
Java- language Lecture 1Java- language Lecture 1
Java- language Lecture 1
Hatem Abd El-Salam
 
[EclipseCon France 2017] Eclipse Platform Generic Editor
[EclipseCon France 2017] Eclipse Platform Generic Editor[EclipseCon France 2017] Eclipse Platform Generic Editor
[EclipseCon France 2017] Eclipse Platform Generic Editor
Mickael Istria
 
Introduction to Core Java Programming
Introduction to Core Java ProgrammingIntroduction to Core Java Programming
Introduction to Core Java Programming
Collaboration Technologies
 
Lets get started by Leif Gensert
Lets get started by Leif GensertLets get started by Leif Gensert
Lets get started by Leif Gensert
Rails Girls MUC
 
Learn java theory presentation
Learn java theory presentationLearn java theory presentation
Learn java theory presentation
Mark John Lado, MIT
 
Go programming language
Go programming languageGo programming language
Go programming language
GoWitek Consulting Pvt.Ltd
 
Java vs python
Java vs pythonJava vs python
Java vs python
Rutuja Gholap
 
C c#
C c#C c#
C c#
Sireesh K
 
Introduction to Java Part-2
Introduction to Java Part-2Introduction to Java Part-2
Introduction to Java Part-2
RatnaJava
 
A walkthrough of JavaScript ES6 features
A walkthrough of JavaScript ES6 featuresA walkthrough of JavaScript ES6 features
A walkthrough of JavaScript ES6 features
Michal Juhas
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
mahir jain
 
Java
JavaJava
Language Workbenches
Language WorkbenchesLanguage Workbenches
Language Workbenches
Mikhail Barash
 
Development workflow
Development workflowDevelopment workflow
Development workflowSigsiu.NET
 

What's hot (20)

PHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the codePHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the code
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
 
EclipseCon Europe 2016, S. Cela, M.Istria: Eclipse Generic and Extensible Edi...
EclipseCon Europe 2016, S. Cela, M.Istria: Eclipse Generic and Extensible Edi...EclipseCon Europe 2016, S. Cela, M.Istria: Eclipse Generic and Extensible Edi...
EclipseCon Europe 2016, S. Cela, M.Istria: Eclipse Generic and Extensible Edi...
 
[EclipseCon France 2017] Language Server Protocol in action
[EclipseCon France 2017] Language Server Protocol in action[EclipseCon France 2017] Language Server Protocol in action
[EclipseCon France 2017] Language Server Protocol in action
 
Java
JavaJava
Java
 
Java- language Lecture 1
Java- language Lecture 1Java- language Lecture 1
Java- language Lecture 1
 
[EclipseCon France 2017] Eclipse Platform Generic Editor
[EclipseCon France 2017] Eclipse Platform Generic Editor[EclipseCon France 2017] Eclipse Platform Generic Editor
[EclipseCon France 2017] Eclipse Platform Generic Editor
 
Introduction to Core Java Programming
Introduction to Core Java ProgrammingIntroduction to Core Java Programming
Introduction to Core Java Programming
 
Lets get started by Leif Gensert
Lets get started by Leif GensertLets get started by Leif Gensert
Lets get started by Leif Gensert
 
Learn java theory presentation
Learn java theory presentationLearn java theory presentation
Learn java theory presentation
 
Go programming language
Go programming languageGo programming language
Go programming language
 
Java vs python
Java vs pythonJava vs python
Java vs python
 
C c#
C c#C c#
C c#
 
Introduction to Java Part-2
Introduction to Java Part-2Introduction to Java Part-2
Introduction to Java Part-2
 
Intro To AOP
Intro To AOPIntro To AOP
Intro To AOP
 
A walkthrough of JavaScript ES6 features
A walkthrough of JavaScript ES6 featuresA walkthrough of JavaScript ES6 features
A walkthrough of JavaScript ES6 features
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
Java
JavaJava
Java
 
Language Workbenches
Language WorkbenchesLanguage Workbenches
Language Workbenches
 
Development workflow
Development workflowDevelopment workflow
Development workflow
 

Similar to Functional solid

Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Codersebbe
 
Solid as OOP abstraction
Solid as OOP abstractionSolid as OOP abstraction
Solid as OOP abstraction
Pawel Klimczyk
 
OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)
David Bosschaert
 
Is your code SOLID enough?
 Is your code SOLID enough? Is your code SOLID enough?
Is your code SOLID enough?
SARCCOM
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
Alfred Jett Grandeza
 
Whats next in templating
Whats next in templatingWhats next in templating
Whats next in templating
Filip Bruun Bech-Larsen
 
Improving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesImproving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design Principles
Dr. Syed Hassan Amin
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
deonpmeyer
 
Java 9, JShell, and Modularity
Java 9, JShell, and ModularityJava 9, JShell, and Modularity
Java 9, JShell, and Modularity
Mohammad Hossein Rimaz
 
FRONTEND BOOTCAMP Session 2.pptx
FRONTEND BOOTCAMP Session 2.pptxFRONTEND BOOTCAMP Session 2.pptx
FRONTEND BOOTCAMP Session 2.pptx
Ehtesham46
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworks
Yuri Visser
 
Code like a ninja session 3 open-closed principle
Code like a ninja  session 3   open-closed principleCode like a ninja  session 3   open-closed principle
Code like a ninja session 3 open-closed principleDeon Meyer
 
Isomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and ReactIsomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and React
Tyler Peterson
 
JAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).pptJAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).ppt
AliyaJav
 
Code reviews
Code reviewsCode reviews
Code reviewsRoger Xia
 
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
mfrancis
 
Whats next in templating
Whats next in templatingWhats next in templating
Whats next in templating
Filip Bruun Bech-Larsen
 
Oracle ADF Architecture TV - Development - Version Control
Oracle ADF Architecture TV - Development - Version ControlOracle ADF Architecture TV - Development - Version Control
Oracle ADF Architecture TV - Development - Version Control
Chris Muir
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
Steve Zhang
 

Similar to Functional solid (20)

Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Code
 
Solid as OOP abstraction
Solid as OOP abstractionSolid as OOP abstraction
Solid as OOP abstraction
 
Solid
SolidSolid
Solid
 
OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)
 
Is your code SOLID enough?
 Is your code SOLID enough? Is your code SOLID enough?
Is your code SOLID enough?
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
 
Whats next in templating
Whats next in templatingWhats next in templating
Whats next in templating
 
Improving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesImproving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design Principles
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
Java 9, JShell, and Modularity
Java 9, JShell, and ModularityJava 9, JShell, and Modularity
Java 9, JShell, and Modularity
 
FRONTEND BOOTCAMP Session 2.pptx
FRONTEND BOOTCAMP Session 2.pptxFRONTEND BOOTCAMP Session 2.pptx
FRONTEND BOOTCAMP Session 2.pptx
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworks
 
Code like a ninja session 3 open-closed principle
Code like a ninja  session 3   open-closed principleCode like a ninja  session 3   open-closed principle
Code like a ninja session 3 open-closed principle
 
Isomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and ReactIsomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and React
 
JAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).pptJAVA object oriented programming (oop).ppt
JAVA object oriented programming (oop).ppt
 
Code reviews
Code reviewsCode reviews
Code reviews
 
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
 
Whats next in templating
Whats next in templatingWhats next in templating
Whats next in templating
 
Oracle ADF Architecture TV - Development - Version Control
Oracle ADF Architecture TV - Development - Version ControlOracle ADF Architecture TV - Development - Version Control
Oracle ADF Architecture TV - Development - Version Control
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
 

Recently uploaded

Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
abdulrafaychaudhry
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
abdulrafaychaudhry
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 

Recently uploaded (20)

Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 

Functional solid

  • 1. Functional SOLID (Can I apply SOLID to FP?) Alexandr Sugak, Software Architect at Sigma Software, https://github.com/AlexSugak
  • 2. SOLID is about OOP OR IS IT?
  • 3. SOLID example https://www.pluralsight.com/courses/encapsulation-solid • Implement a message store; • Messages are stored as files on disk; • Messages are cached; • Access to messages is logged.
  • 4. SRP: one reason to change • A module/class must encapsulate one thing; • How to find this one thing? • RCM’s answer: object must have one reason for change.
  • 6. OCP: closed for modification • Could it be that behavior of a class/module may be extended/changed in future? • How can we extract this reason for change as an abstraction? • How can we program that class/module once and for all (close it)?
  • 7. OCP: opened for extensibility It is agreed that usually it is better to achieve extensibility and reuse by composition instead of inheritance. https://en.wikipedia.org/wiki/Composition_over_inheritance GoF: “Ideally you shouldn’t have to create new components to achieve reuse. You should be able to get all the functionality you need just by assembling existing components through object composition. But this is rarely the case, because the set of available components is never quite rich enough in practice. Reuse by inheritance makes it easier to make new components that can be composed with old ones. Inheritance and object composition thus work together. Nevertheless, our experience is that designers overuse inheritance as a reuse technique and designs are often made more reusable (and simpler) by depending more on object composition. You’ll see object composition applied again and again in the design patterns.”
  • 8. OCP: cache store via decorator
  • 9. LSP: conforming to semantics of an abstraction What can we assume about implementation of abstraction? • Command Query Separation; • Strong typing enforces semantics; • Maybe<T> instead of nulls; • Strongly typed errors; • Code Contracts; • Checked exceptions in Java; • Etc.
  • 11. ISP: do not depend on things you do not use • The smallest interface has one method; • You cannot violate ISP if all interfaces have one method.
  • 13. DIP: high must not depend on low • Both must depend on abstraction; • Programming against interfaces.
  • 15. SOLID Message Store: decorators everywhere! https://www.pluralsight.com/courses/encapsulation-solid
  • 16. Extreme SOLID results in • A bunch of one-method interfaces;
  • 17. Extreme SOLID results in • A bunch of one-method interfaces; • A lot of small one/two-method classes;
  • 18. Extreme SOLID results in • A bunch of one-method interfaces; • A lot of small one/two-method classes; • Decorators everywhere;
  • 19. Extreme SOLID results in • A bunch of one-method interfaces; • A lot of small one/two-method classes; • Decorators everywhere; • Compositions of complex behaviors out of simple classes;
  • 20. Extreme SOLID results in • A bunch of one-method interfaces; • A lot of small one/two-method classes; • Decorators everywhere; • Compositions of complex behaviors out of simple classes; • Other developers don’t like to work with such code base.
  • 23. Extreme SOLID results in doing this: https://github.com/AlexSugak/concurrencysample
  • 25. Doing SOLID in OO requires experience and discipline: • Such code is not idiomatic to C# or Java; • Our tools (IDE) are not optimized for this; • Majority of developers are not used to this; • Requires deep knowledge and understanding in majority of the team.
  • 26. SOLID in FP OOP FP One-method interfaces One-method classes Decorators Composition
  • 27. SOLID in FP OOP FP One-method interfaces Functions One-method classes Functions Decorators Functions Composition Function composition
  • 28. Message Store in F#, types: https://github.com/AlexSugak/message-store
  • 29. Message Store in F#, types:
  • 30. Message Store in F#, types:
  • 34. Message Store in F#, file store:
  • 35. Message Store in F#, store cache:
  • 36. Message Store in F#, store logger:
  • 37. Message Store in F#, composition:
  • 38. Message Store in F#, composition:
  • 39. Message Store in F#, composition:
  • 40. Message Store in F#, simpler: http://www.fssnip.net/h4
  • 41. SOLID in FP, simpler, easier: • Coming up with a good abstraction is hard; • PL should help with that, not make it more difficult; • FP focuses on types, function signatures, composition, making it easier to reason about abstractions; • The result artifact is usually simpler.

Editor's Notes

  1. Example with collections in .Net