SlideShare a Scribd company logo
1 of 75
Craft predictable web apps with F#
Kevin Avignon
Kavignon @ GitHub & Twitter
Clients want the best product delivered quickly
Plan of the evening
What is domain modeling?
Representing store products with F#
Emulate business requirements in the domain
Simulate store browsing with Fable & Elmish
My backstory
Software developer Hypertherm Robotics Software
Career focused on .NET
Web, Desktop & Tools
An enthusiast of functional programming and .NET
Discovered F# in 2016
Incorporated F# at work and we now have 3 production tools
Blogging on tech @ www.kevinavignon.com
Why should you listen to what I have to say today?
Reasons to be here today
You’ve never heard of F# before and you’re intrigued
Javascript gives you nightmares and you want to stop using it
Full-stack development is hard and you’re looking for ways to make it easier
You’d like to catch bugs earlier in your development
What is domain modelling?
Why use it?
Meaningful representation of concepts needed to be replicated by
software
Giving both experts and developers a shared mental model
Making requirements explicit in the system
Setting it up
Focus on the inputs and outputs in the real-world
Capture both requirements and potential min/max
Avoid thinking of low-level designs too early
Divide & Conquer - Bounded Context
Smaller domains representing portions of the problem space
Clear boundaries to avoid coupling from problem space
Contexts should be autonomous
Must have a way to communicate with each other if needed
Data Transfer Object vs Domain
objects
Domain objects: Objects defined inside the bounded context
Data transfer object (DTO): Only used for serialization and
communication between bounded contexts
Commands, Domain Events &
Workflows
Command (Input): Data object sent to the domain to request a change
Event (Output): Abstraction of the changes that occurred inside the
domain
Workflow
Process triggered by a command
Outputs a set of domain events
Now we know domain modeling.
What about functional programming?
FP vs OO approaches in hindsight
OO FP
Handling state Allowing mutation No mutation
Building blocks Classes and objects Functions
Reduced coupling
Interfaces, abstract classes
& dependency injection
Functions
Code reuse Inheritance Function composition
Program actions Statements Expressions
Functions
Pure Impure
Side-effect free Depends
Same input = same output Depends
Easy to compose Depends
Easy to test Hard to test
C# Programmers of today use some functional concepts
Some functional concepts in C#
Strings
Once set, their values don’t change
Getter-only auto-properties
LINQ
Tuples
Immutability by default
Nothing changes after the data has been set
You have 100% control on data updates
No more obscure unwanted mutation at runtime
If C# already supports functional programming,
why bother learning a new language for .NET?
1. Picking the right tools for the job
Law of the instrument
C# is really good for OO software projects
C# wasn’t created with functional programming in mind
Functions are second-citizen
Mutation is by default
Syntax is pretty verbose
I suppose it is tempting, if the only tool you have is a hammer, to treat
everything as if it were a nail
- Abraham Maslow
2. Testimonials from companies
Gamesys Testimonial
They’ve observed an increase in productivity
Allowed one developer to replace an entire Java team
Rules engine for social slot games served 700,000 unique players and
150,000,000 requests per day
Bayad Rock Testimonial
“F# succinctness allowed to rapidly iterate on new ideas”
“The type system acted as a safety net”
“F# has given us a great advantage over slower competitors”
“3 years in and our products are getting significantly better without
sacrificing stability”
3. Embraced by big players
List of companies using F# - https://github.com/Kavignon/fsharp-companies
4. Predictable behaviour
Anticipated inner workings
Values must be initialized with valid states
Comparing values of different types is a compile-time error
Values are immutable by default
Records with the same data are equal by default
Case Study: Building an e-commerce web application
Representing store products
Laptop
Discriminated Union
Record
Optional values instead of nulls
Type inference
Automatic detection of your data type
Makes the code more concise
Representing Store Products
Type Provider (XML)
Pattern matching
Pipe operators (forward)
15 minutes break
Business Requirements
Authenticated users can add products to their shopping cart.
Authenticated users can remove products from their shopping cart.
Authenticated users can consult their previous orders.
An authenticated user can update their payment method from his account.
A successful order will be confirmed will an automatic email with the order summary.
Designing with types
Represent your domain entities and actions with
Discriminated unions
Records
Function signatures
Reasons behind type driven
development
Business logic can be complicated
Logic abstracted through types is self-documenting
Example:
I want to add two copies of a book to the cart
Example:
Sending an acknowledgement to a customer’s email
Format email based on culture
Spanish (Spain)
English (Canada)
Only when the order has been validated
Emulating browsing of store products with F#
What is
F# application development stack for web development
Made of 4 components
1. A .NET Core web server [S]
2. A hosting platform (i.e. Azure) [A]
3. A mechanism to run F# client code inside the browser [F]
4. An F# model to develop client-side UIs [E]
?
Why is it interesting for a .NET dev?
Type safe programming from back-end to front-end with F#
Allows code sharing with back-end and front-end
No need to be an expert of CSS or Javascript
Many frameworks for front-end
A few words on
Preferred to be referred as a library, not a framework
Creating reusable UI components (i.e. forms, dropdowns, etc)
Embraces FP
Declarative programming model
Immutability is preferred
Do I have to use React with SAFE?
Short answer, no
React is used because of its FP-nature
You can create your own bindings to JS library/framework
So what’s Saturn?
Web development library for F#
Used for both web server APIs and MVC apps
Sits on top of ASP.NET Core
Hosts your client assets (HTML/CSS & Js) generated by Fable
F is for Fable
F# to Javascript compiler
Produces readable Javascript for browsers
Integrates with JS
Can use JS libs from F# and vice-versa
Powered by Babel
Toolchain to convert ES5 in backwards compatible Javascript
E as Elmish
Set of abstractions for writing user interfaces in F#
Embraces the Model-View-Update pattern made popular by Elm (FP
lang)
Provides an solid UI-independent core
Overview of Elmish concepts
Model - Snapshot of the application’s state (immutable)
Message - Event representing a change in the app (i.e initial loading)
Command - Carrier of instructions
May results to more than 1 message
Update - Pure function new app state from the previous snapshot
View - Pure function that generates a new layout/content
Uses a rendering engine such as React’s
Demo
Recommended Resources
Beginner friendly F# resources
F# for C# programmers: https://www.youtube.com/watch?v=KPa8Yw_Navk
Functional Design Patterns: https://www.youtube.com/watch?v=srQt1NAHYC0
The Power of Composition: https://www.youtube.com/watch?v=vDe-4o8Uwl8
The functional programming toolkit: https://www.youtube.com/watch?v=Nrp_LZ-XGsY
Functional programming with F# series:
https://www.youtube.com/playlist?list=PLEoMzSkcN8oNiJ67Hd7oRGgD1d4YBxYGC
F# for fun and profit: https://fsharpforfunandprofit.com/
F# Workshop: http://www.fsharpworkshop.com/
SAFE Tutorials
SAFE Dojo: https://github.com/CompositionalIT/SAFE-Dojo/
Introduction to the Elm architecture with Elmish F# and Fable:
https://www.youtube.com/watch?v=3Qk4bWs7vrs
Let’s build a TODO list with React, Elmish, F# & Fable:
https://www.youtube.com/watch?v=zAfW_-m1u4k
Let’s talk HTTP with React, Elmish F# & Fable:
https://www.youtube.com/watch?v=_2U4pDj6tng
Hackers news clone with SAFE: https://www.youtube.com/watch?v=w0Am8fRQzGg
From F# to Javascript with Fable: https://www.youtube.com/watch?v=5191ytFmG_A
SAFE Resources
SAFE Stack docs: https://safe-stack.github.io/docs/
Saturn docs: https://saturnframework.org/docs/
Elmish docs: https://elmish.github.io/elmish/
SAFE Mock-Commerce: https://github.com/Kavignon/.NETDemoCode/tree/master/SAFE-
Mock-Commerce
SAFE BookStore: https://github.com/SAFE-Stack/SAFE-BookStore
SAFE Chat: https://github.com/SAFE-Stack/SAFE-Chat
SAFE Search: https://github.com/SAFE-Stack/SAFE-Search
Tabula Rasa - Minimalist blog engine: https://github.com/Zaid-Ajaj/tabula-rasa
SAFE Tools Resources
SAFE Template - Basic template to get started: https://github.com/SAFE-
Stack/SAFE-template
Fable.Remoting - type safe communication layer between client & server:
https://github.com/Zaid-Ajaj/Fable.Remoting
Femto - CLI tool to resolve npm/yarn packages: https://github.com/Zaid-Ajaj/Femto
Feliz - DSL for React development in F#: https://github.com/Zaid-Ajaj/Feliz
Feliz.Router - Elmish router with Feliz: https://github.com/Zaid-Ajaj/Feliz.Router
Feliz.MaterialUI - Fable bindings with Feliz DSL to MaterialUI:
https://github.com/cmeeren/Feliz.MaterialUI
Learning React Resources
Intro to React: https://reactjs.org/tutorial/tutorial.html
Introduction to React and Intermediate React: https://btholt.github.io/complete-
intro-to-react-v5/
Any questions?

More Related Content

What's hot

Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Peter Hendriks
 
RAML - APIs By Design
RAML - APIs By DesignRAML - APIs By Design
RAML - APIs By DesignUri Sarid
 
Cross Platform Development in C# (DDDNorth 2013)
Cross Platform Development in C# (DDDNorth 2013)Cross Platform Development in C# (DDDNorth 2013)
Cross Platform Development in C# (DDDNorth 2013)ross.dargan
 
Why do developers prefer ionic to build progressive web apps
Why do developers prefer ionic to build progressive web apps  Why do developers prefer ionic to build progressive web apps
Why do developers prefer ionic to build progressive web apps Moon Technolabs Pvt. Ltd.
 
Getting Acquainted with PhoneGap
Getting Acquainted with PhoneGapGetting Acquainted with PhoneGap
Getting Acquainted with PhoneGapJoseph Labrecque
 
Cross platform mobile application development
Cross platform mobile application developmentCross platform mobile application development
Cross platform mobile application developmentwebprogr.com
 
Flex on Grails - Rich Internet Applications With Rapid Application Development
Flex on Grails - Rich Internet Applications With Rapid Application DevelopmentFlex on Grails - Rich Internet Applications With Rapid Application Development
Flex on Grails - Rich Internet Applications With Rapid Application DevelopmentTalentica Software
 
vpTech - Practical F# in Finance
vpTech - Practical F# in FinancevpTech - Practical F# in Finance
vpTech - Practical F# in FinanceAmin Khansari
 
Top 10 php frameworks in 2021
Top 10 php frameworks in 2021Top 10 php frameworks in 2021
Top 10 php frameworks in 2021MaryamAnwar10
 
Using JavaScript for Mobile Development
Using JavaScript for Mobile DevelopmentUsing JavaScript for Mobile Development
Using JavaScript for Mobile DevelopmentStephen G
 
SynapseIndia gives an overview on comparison in PHP & ASP.NET in Terms of Cos...
SynapseIndia gives an overview on comparison in PHP & ASP.NET in Terms of Cos...SynapseIndia gives an overview on comparison in PHP & ASP.NET in Terms of Cos...
SynapseIndia gives an overview on comparison in PHP & ASP.NET in Terms of Cos...SynapseIndia
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothBhavsingh Maloth
 
PhoneGap Talk @ Sencha Con 2010
PhoneGap Talk @ Sencha Con 2010PhoneGap Talk @ Sencha Con 2010
PhoneGap Talk @ Sencha Con 2010alunny
 

What's hot (19)

Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)
 
RAML - APIs By Design
RAML - APIs By DesignRAML - APIs By Design
RAML - APIs By Design
 
Cross Platform Development in C# (DDDNorth 2013)
Cross Platform Development in C# (DDDNorth 2013)Cross Platform Development in C# (DDDNorth 2013)
Cross Platform Development in C# (DDDNorth 2013)
 
Why do developers prefer ionic to build progressive web apps
Why do developers prefer ionic to build progressive web apps  Why do developers prefer ionic to build progressive web apps
Why do developers prefer ionic to build progressive web apps
 
Codename one
Codename oneCodename one
Codename one
 
Getting Acquainted with PhoneGap
Getting Acquainted with PhoneGapGetting Acquainted with PhoneGap
Getting Acquainted with PhoneGap
 
Cross platform mobile application development
Cross platform mobile application developmentCross platform mobile application development
Cross platform mobile application development
 
Flex on Grails - Rich Internet Applications With Rapid Application Development
Flex on Grails - Rich Internet Applications With Rapid Application DevelopmentFlex on Grails - Rich Internet Applications With Rapid Application Development
Flex on Grails - Rich Internet Applications With Rapid Application Development
 
vpTech - Practical F# in Finance
vpTech - Practical F# in FinancevpTech - Practical F# in Finance
vpTech - Practical F# in Finance
 
Java By Sai NagaVenkata BuchiBabu Manepalli
Java By Sai NagaVenkata BuchiBabu ManepalliJava By Sai NagaVenkata BuchiBabu Manepalli
Java By Sai NagaVenkata BuchiBabu Manepalli
 
Beginning PHP
Beginning PHPBeginning PHP
Beginning PHP
 
Phone gap
Phone gapPhone gap
Phone gap
 
Top 10 php frameworks in 2021
Top 10 php frameworks in 2021Top 10 php frameworks in 2021
Top 10 php frameworks in 2021
 
Phonegap - An Overview
Phonegap - An OverviewPhonegap - An Overview
Phonegap - An Overview
 
Using JavaScript for Mobile Development
Using JavaScript for Mobile DevelopmentUsing JavaScript for Mobile Development
Using JavaScript for Mobile Development
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
SynapseIndia gives an overview on comparison in PHP & ASP.NET in Terms of Cos...
SynapseIndia gives an overview on comparison in PHP & ASP.NET in Terms of Cos...SynapseIndia gives an overview on comparison in PHP & ASP.NET in Terms of Cos...
SynapseIndia gives an overview on comparison in PHP & ASP.NET in Terms of Cos...
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh Maloth
 
PhoneGap Talk @ Sencha Con 2010
PhoneGap Talk @ Sencha Con 2010PhoneGap Talk @ Sencha Con 2010
PhoneGap Talk @ Sencha Con 2010
 

Similar to Domain Modeling & Full-Stack Web Development F#

NET Event - Migrating WinForm
NET Event - Migrating WinFormNET Event - Migrating WinForm
NET Event - Migrating WinFormRaffaele Garofalo
 
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem.
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem. SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem.
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem. Kushan Lahiru Perera
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arpGary Pedretti
 
Mobile app development using PhoneGap - A comprehensive walkthrough - Touch T...
Mobile app development using PhoneGap - A comprehensive walkthrough - Touch T...Mobile app development using PhoneGap - A comprehensive walkthrough - Touch T...
Mobile app development using PhoneGap - A comprehensive walkthrough - Touch T...RIA RUI Society
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowKaxil Naik
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan
 
Modern Frontend Technology
Modern Frontend TechnologyModern Frontend Technology
Modern Frontend TechnologyShip Hsu
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with PythonBrian Lyttle
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworksYuri Visser
 
JQuery Mobile vs Appcelerator Titanium vs Sencha Touch
JQuery Mobile vs Appcelerator Titanium vs Sencha TouchJQuery Mobile vs Appcelerator Titanium vs Sencha Touch
JQuery Mobile vs Appcelerator Titanium vs Sencha TouchSteve Drucker
 
Titanium presentation
Titanium presentationTitanium presentation
Titanium presentationaaltavas
 
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...JPLoft Solutions
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Mack Hardy
 
Generative AI in CSharp with Semantic Kernel.pptx
Generative AI in CSharp with Semantic Kernel.pptxGenerative AI in CSharp with Semantic Kernel.pptx
Generative AI in CSharp with Semantic Kernel.pptxAlon Fliess
 
Be04 introduction to ef 6.0
Be04   introduction to ef 6.0Be04   introduction to ef 6.0
Be04 introduction to ef 6.0DotNetCampus
 
System design for Web Application
System design for Web ApplicationSystem design for Web Application
System design for Web ApplicationMichael Choi
 
Bn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot netBn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot netconline training
 

Similar to Domain Modeling & Full-Stack Web Development F# (20)

NET Event - Migrating WinForm
NET Event - Migrating WinFormNET Event - Migrating WinForm
NET Event - Migrating WinForm
 
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem.
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem. SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem.
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem.
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
 
Mobile app development using PhoneGap - A comprehensive walkthrough - Touch T...
Mobile app development using PhoneGap - A comprehensive walkthrough - Touch T...Mobile app development using PhoneGap - A comprehensive walkthrough - Touch T...
Mobile app development using PhoneGap - A comprehensive walkthrough - Touch T...
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache Airflow
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2
 
Modern Frontend Technology
Modern Frontend TechnologyModern Frontend Technology
Modern Frontend Technology
 
Web Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptxWeb Dev 21-01-2024.pptx
Web Dev 21-01-2024.pptx
 
Krishnagopal Thogiti_Java
Krishnagopal Thogiti_JavaKrishnagopal Thogiti_Java
Krishnagopal Thogiti_Java
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworks
 
JQuery Mobile vs Appcelerator Titanium vs Sencha Touch
JQuery Mobile vs Appcelerator Titanium vs Sencha TouchJQuery Mobile vs Appcelerator Titanium vs Sencha Touch
JQuery Mobile vs Appcelerator Titanium vs Sencha Touch
 
Titanium presentation
Titanium presentationTitanium presentation
Titanium presentation
 
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
Generative AI in CSharp with Semantic Kernel.pptx
Generative AI in CSharp with Semantic Kernel.pptxGenerative AI in CSharp with Semantic Kernel.pptx
Generative AI in CSharp with Semantic Kernel.pptx
 
Be04 introduction to ef 6.0
Be04   introduction to ef 6.0Be04   introduction to ef 6.0
Be04 introduction to ef 6.0
 
System design for Web Application
System design for Web ApplicationSystem design for Web Application
System design for Web Application
 
Expo - Zero to App.pptx
Expo - Zero to App.pptxExpo - Zero to App.pptx
Expo - Zero to App.pptx
 
Bn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot netBn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot net
 

Recently uploaded

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 

Recently uploaded (20)

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 

Domain Modeling & Full-Stack Web Development F#

  • 1. Craft predictable web apps with F# Kevin Avignon Kavignon @ GitHub & Twitter
  • 2. Clients want the best product delivered quickly
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. Plan of the evening What is domain modeling? Representing store products with F# Emulate business requirements in the domain Simulate store browsing with Fable & Elmish
  • 10. Software developer Hypertherm Robotics Software Career focused on .NET Web, Desktop & Tools An enthusiast of functional programming and .NET Discovered F# in 2016 Incorporated F# at work and we now have 3 production tools Blogging on tech @ www.kevinavignon.com
  • 11. Why should you listen to what I have to say today?
  • 12. Reasons to be here today You’ve never heard of F# before and you’re intrigued Javascript gives you nightmares and you want to stop using it Full-stack development is hard and you’re looking for ways to make it easier You’d like to catch bugs earlier in your development
  • 13. What is domain modelling?
  • 14. Why use it? Meaningful representation of concepts needed to be replicated by software Giving both experts and developers a shared mental model Making requirements explicit in the system
  • 15. Setting it up Focus on the inputs and outputs in the real-world Capture both requirements and potential min/max Avoid thinking of low-level designs too early
  • 16. Divide & Conquer - Bounded Context Smaller domains representing portions of the problem space Clear boundaries to avoid coupling from problem space Contexts should be autonomous Must have a way to communicate with each other if needed
  • 17. Data Transfer Object vs Domain objects Domain objects: Objects defined inside the bounded context Data transfer object (DTO): Only used for serialization and communication between bounded contexts
  • 18. Commands, Domain Events & Workflows Command (Input): Data object sent to the domain to request a change Event (Output): Abstraction of the changes that occurred inside the domain Workflow Process triggered by a command Outputs a set of domain events
  • 19. Now we know domain modeling. What about functional programming?
  • 20. FP vs OO approaches in hindsight OO FP Handling state Allowing mutation No mutation Building blocks Classes and objects Functions Reduced coupling Interfaces, abstract classes & dependency injection Functions Code reuse Inheritance Function composition Program actions Statements Expressions
  • 21. Functions Pure Impure Side-effect free Depends Same input = same output Depends Easy to compose Depends Easy to test Hard to test
  • 22. C# Programmers of today use some functional concepts
  • 23. Some functional concepts in C# Strings Once set, their values don’t change Getter-only auto-properties LINQ Tuples
  • 24.
  • 25. Immutability by default Nothing changes after the data has been set You have 100% control on data updates No more obscure unwanted mutation at runtime
  • 26. If C# already supports functional programming, why bother learning a new language for .NET?
  • 27. 1. Picking the right tools for the job
  • 28. Law of the instrument C# is really good for OO software projects C# wasn’t created with functional programming in mind Functions are second-citizen Mutation is by default Syntax is pretty verbose
  • 29. I suppose it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail - Abraham Maslow
  • 30. 2. Testimonials from companies
  • 31. Gamesys Testimonial They’ve observed an increase in productivity Allowed one developer to replace an entire Java team Rules engine for social slot games served 700,000 unique players and 150,000,000 requests per day
  • 32. Bayad Rock Testimonial “F# succinctness allowed to rapidly iterate on new ideas” “The type system acted as a safety net” “F# has given us a great advantage over slower competitors” “3 years in and our products are getting significantly better without sacrificing stability”
  • 33. 3. Embraced by big players
  • 34. List of companies using F# - https://github.com/Kavignon/fsharp-companies
  • 36. Anticipated inner workings Values must be initialized with valid states Comparing values of different types is a compile-time error Values are immutable by default Records with the same data are equal by default
  • 37. Case Study: Building an e-commerce web application
  • 43. Type inference Automatic detection of your data type Makes the code more concise
  • 45.
  • 50. Business Requirements Authenticated users can add products to their shopping cart. Authenticated users can remove products from their shopping cart. Authenticated users can consult their previous orders. An authenticated user can update their payment method from his account. A successful order will be confirmed will an automatic email with the order summary.
  • 51. Designing with types Represent your domain entities and actions with Discriminated unions Records Function signatures
  • 52. Reasons behind type driven development Business logic can be complicated Logic abstracted through types is self-documenting
  • 53. Example: I want to add two copies of a book to the cart Example: Sending an acknowledgement to a customer’s email Format email based on culture Spanish (Spain) English (Canada) Only when the order has been validated
  • 54. Emulating browsing of store products with F#
  • 55. What is F# application development stack for web development Made of 4 components 1. A .NET Core web server [S] 2. A hosting platform (i.e. Azure) [A] 3. A mechanism to run F# client code inside the browser [F] 4. An F# model to develop client-side UIs [E] ?
  • 56. Why is it interesting for a .NET dev? Type safe programming from back-end to front-end with F# Allows code sharing with back-end and front-end No need to be an expert of CSS or Javascript
  • 57. Many frameworks for front-end
  • 58. A few words on Preferred to be referred as a library, not a framework Creating reusable UI components (i.e. forms, dropdowns, etc) Embraces FP Declarative programming model Immutability is preferred
  • 59. Do I have to use React with SAFE? Short answer, no React is used because of its FP-nature You can create your own bindings to JS library/framework
  • 60. So what’s Saturn? Web development library for F# Used for both web server APIs and MVC apps Sits on top of ASP.NET Core Hosts your client assets (HTML/CSS & Js) generated by Fable
  • 61. F is for Fable F# to Javascript compiler Produces readable Javascript for browsers Integrates with JS Can use JS libs from F# and vice-versa Powered by Babel Toolchain to convert ES5 in backwards compatible Javascript
  • 62. E as Elmish Set of abstractions for writing user interfaces in F# Embraces the Model-View-Update pattern made popular by Elm (FP lang) Provides an solid UI-independent core
  • 63. Overview of Elmish concepts Model - Snapshot of the application’s state (immutable) Message - Event representing a change in the app (i.e initial loading) Command - Carrier of instructions May results to more than 1 message Update - Pure function new app state from the previous snapshot View - Pure function that generates a new layout/content Uses a rendering engine such as React’s
  • 64. Demo
  • 66. Beginner friendly F# resources F# for C# programmers: https://www.youtube.com/watch?v=KPa8Yw_Navk Functional Design Patterns: https://www.youtube.com/watch?v=srQt1NAHYC0 The Power of Composition: https://www.youtube.com/watch?v=vDe-4o8Uwl8 The functional programming toolkit: https://www.youtube.com/watch?v=Nrp_LZ-XGsY Functional programming with F# series: https://www.youtube.com/playlist?list=PLEoMzSkcN8oNiJ67Hd7oRGgD1d4YBxYGC F# for fun and profit: https://fsharpforfunandprofit.com/ F# Workshop: http://www.fsharpworkshop.com/
  • 67. SAFE Tutorials SAFE Dojo: https://github.com/CompositionalIT/SAFE-Dojo/ Introduction to the Elm architecture with Elmish F# and Fable: https://www.youtube.com/watch?v=3Qk4bWs7vrs Let’s build a TODO list with React, Elmish, F# & Fable: https://www.youtube.com/watch?v=zAfW_-m1u4k Let’s talk HTTP with React, Elmish F# & Fable: https://www.youtube.com/watch?v=_2U4pDj6tng Hackers news clone with SAFE: https://www.youtube.com/watch?v=w0Am8fRQzGg From F# to Javascript with Fable: https://www.youtube.com/watch?v=5191ytFmG_A
  • 68. SAFE Resources SAFE Stack docs: https://safe-stack.github.io/docs/ Saturn docs: https://saturnframework.org/docs/ Elmish docs: https://elmish.github.io/elmish/ SAFE Mock-Commerce: https://github.com/Kavignon/.NETDemoCode/tree/master/SAFE- Mock-Commerce SAFE BookStore: https://github.com/SAFE-Stack/SAFE-BookStore SAFE Chat: https://github.com/SAFE-Stack/SAFE-Chat SAFE Search: https://github.com/SAFE-Stack/SAFE-Search Tabula Rasa - Minimalist blog engine: https://github.com/Zaid-Ajaj/tabula-rasa
  • 69. SAFE Tools Resources SAFE Template - Basic template to get started: https://github.com/SAFE- Stack/SAFE-template Fable.Remoting - type safe communication layer between client & server: https://github.com/Zaid-Ajaj/Fable.Remoting Femto - CLI tool to resolve npm/yarn packages: https://github.com/Zaid-Ajaj/Femto Feliz - DSL for React development in F#: https://github.com/Zaid-Ajaj/Feliz Feliz.Router - Elmish router with Feliz: https://github.com/Zaid-Ajaj/Feliz.Router Feliz.MaterialUI - Fable bindings with Feliz DSL to MaterialUI: https://github.com/cmeeren/Feliz.MaterialUI
  • 70. Learning React Resources Intro to React: https://reactjs.org/tutorial/tutorial.html Introduction to React and Intermediate React: https://btholt.github.io/complete- intro-to-react-v5/
  • 71.
  • 72.
  • 73.
  • 74.

Editor's Notes

  1. Genetec Capstone project Introducing F# at work Great F# community Great F# projects at work
  2. Not always a 1:1 mapping from problem to solution space Make sure boundaries don’t creep Listen to your domain experts Document concepts and vocabulary of the context Emphasis on autonomy for the contexts Capturing business logic more intuitively