The lazy programmer's guide to writing thousands of testsScott Wlaschin
We are all familiar with example-based testing, as typified by TDD and BDD, where each test is hand-crafted.
But there's another approach to writing tests. In the "property-based testing" approach, a single test is run hundreds of times with randomly generated inputs. Property-based testing is a great way to find edge cases, and also helps you to understand and document the behavior of your code under all conditions.
This talk will introduce property-based testing, show you how it works, and demonstrate why you should consider adding this powerful technique to your toolbelt.
(Video of these slides here http://fsharpforfunandprofit.com/rop)
(My response to "this is just Either" here: http://fsharpforfunandprofit.com/rop/#monads)
Many examples in functional programming assume that you are always on the "happy path". But to create a robust real world application you must deal with validation, logging, network and service errors, and other annoyances.
So, how do you handle all this in a clean functional way? This talk will provide a brief introduction to this topic, using a fun and easy-to-understand railway analogy.
What is a declarative HTTP client vs. an imperative one? Why are they useful and why should I care? We’ll talk about options that are available in the Spring portfolio and what’s coming on the horizon. In this session, we’ll look at the history of declarative clients in Spring via Spring Cloud OpenFeign. We’ll also dive into upcoming options that are coming to Spring and the advantages that these new technologies bring to the developer experience. Spring One Tour Tel-Aviv 2022.
Composition is a fundamental principle of functional programming, but how is it different from an object-oriented approach, and how do you use it in practice?
In this talk for beginners, we'll start by going over the basic concepts of functional programming, and then look at some different ways that composition can be used to build large things from small things.
After that, we'll see how composition is used in practice, beginning with a simple FizzBuzz example, and ending with a complete (object-free!) web application.
10 years after the release of the original book Domain Driven Design by Eric Evans we are seeing more and more applications built on the core concepts of DDD. Still, there is a long way to go before we fully grasp all its potential. First we need to change the way we do things in our projects. In this session I will show a possible implementation in C# that I've been using in many projects.
The lazy programmer's guide to writing thousands of testsScott Wlaschin
We are all familiar with example-based testing, as typified by TDD and BDD, where each test is hand-crafted.
But there's another approach to writing tests. In the "property-based testing" approach, a single test is run hundreds of times with randomly generated inputs. Property-based testing is a great way to find edge cases, and also helps you to understand and document the behavior of your code under all conditions.
This talk will introduce property-based testing, show you how it works, and demonstrate why you should consider adding this powerful technique to your toolbelt.
(Video of these slides here http://fsharpforfunandprofit.com/rop)
(My response to "this is just Either" here: http://fsharpforfunandprofit.com/rop/#monads)
Many examples in functional programming assume that you are always on the "happy path". But to create a robust real world application you must deal with validation, logging, network and service errors, and other annoyances.
So, how do you handle all this in a clean functional way? This talk will provide a brief introduction to this topic, using a fun and easy-to-understand railway analogy.
What is a declarative HTTP client vs. an imperative one? Why are they useful and why should I care? We’ll talk about options that are available in the Spring portfolio and what’s coming on the horizon. In this session, we’ll look at the history of declarative clients in Spring via Spring Cloud OpenFeign. We’ll also dive into upcoming options that are coming to Spring and the advantages that these new technologies bring to the developer experience. Spring One Tour Tel-Aviv 2022.
Composition is a fundamental principle of functional programming, but how is it different from an object-oriented approach, and how do you use it in practice?
In this talk for beginners, we'll start by going over the basic concepts of functional programming, and then look at some different ways that composition can be used to build large things from small things.
After that, we'll see how composition is used in practice, beginning with a simple FizzBuzz example, and ending with a complete (object-free!) web application.
10 years after the release of the original book Domain Driven Design by Eric Evans we are seeing more and more applications built on the core concepts of DDD. Still, there is a long way to go before we fully grasp all its potential. First we need to change the way we do things in our projects. In this session I will show a possible implementation in C# that I've been using in many projects.
(Video and code at https://fsharpforfunandprofit.com/pipeline/)
Passing data through a pipeline of transformations is an alternative approach to classic OOP. The LINQ methods in .NET are designed around this, but the pipeline approach can be used for so much more than manipulating collections.
In this talk, I'll look at pipeline-oriented programming and how it relates to functional programming, the open-closed principle, unit testing, the onion architecture, and more. I'll finish up by showing how you can build a complete web app using only this approach.
(video and more at http://fsharpforfunandprofit.com/fppatterns)
In object-oriented development, we are all familiar with design patterns such as the Strategy pattern and Decorator pattern, and design principles such as SOLID. The functional programming community has design patterns and principles as well. This talk will provide an overview of some of these patterns (such as currying, monads), and present some demonstrations of FP design in practice. We'll also look at some of the ways you can use these patterns as part of a domain driven design process, with some simple real world examples in F#. No jargon, no maths, and no prior F# experience necessary.
(Video and code at http://fsharpforfunandprofit.com/composition)
Composition is a fundamental principle of functional programming, but how is it different from an object-oriented approach, and how do you use it in practice?
In this talk for beginners, we'll start by going over the basic concepts of functional programming, and then look at some different ways that composition can be used to build large things from small things.
After that, we'll see how composition is used in practice, beginning with a simple FizzBuzz example, and ending with a complete (object-free!) web application.
What's LINQ, its advantages, its Operators and examples on some of them, Methods of Writing it.
LINQ to Objects and Collections and Data Source Transformation.
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1Philip Schwarz
slides can look grainy and/or out of focus when seen on slideshare - download for flawless quality - Based on Scott Wlaschin’s great book 'Domain Modeling Made Functional' and on Martin Odersky's talk 'A Tour of Scala 3'.
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...PROIDEA
Object-oriented programming languages have been here for decades, helping millions of developers to deliver (sort of) working software. Still, after many years, we still struggle with things like nulls and exceptions, which make our applications crash in most unexpected ways. So I have taken a challenge - can you use object-oriented language (C#) and write code in a way that those issues are almost gone? I will show how to leverage lessons learned from functional programming to make our applications more bulletproof - and fun to write as well!
(Video and code at https://fsharpforfunandprofit.com/pipeline/)
Passing data through a pipeline of transformations is an alternative approach to classic OOP. The LINQ methods in .NET are designed around this, but the pipeline approach can be used for so much more than manipulating collections.
In this talk, I'll look at pipeline-oriented programming and how it relates to functional programming, the open-closed principle, unit testing, the onion architecture, and more. I'll finish up by showing how you can build a complete web app using only this approach.
(video and more at http://fsharpforfunandprofit.com/fppatterns)
In object-oriented development, we are all familiar with design patterns such as the Strategy pattern and Decorator pattern, and design principles such as SOLID. The functional programming community has design patterns and principles as well. This talk will provide an overview of some of these patterns (such as currying, monads), and present some demonstrations of FP design in practice. We'll also look at some of the ways you can use these patterns as part of a domain driven design process, with some simple real world examples in F#. No jargon, no maths, and no prior F# experience necessary.
(Video and code at http://fsharpforfunandprofit.com/composition)
Composition is a fundamental principle of functional programming, but how is it different from an object-oriented approach, and how do you use it in practice?
In this talk for beginners, we'll start by going over the basic concepts of functional programming, and then look at some different ways that composition can be used to build large things from small things.
After that, we'll see how composition is used in practice, beginning with a simple FizzBuzz example, and ending with a complete (object-free!) web application.
What's LINQ, its advantages, its Operators and examples on some of them, Methods of Writing it.
LINQ to Objects and Collections and Data Source Transformation.
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1Philip Schwarz
slides can look grainy and/or out of focus when seen on slideshare - download for flawless quality - Based on Scott Wlaschin’s great book 'Domain Modeling Made Functional' and on Martin Odersky's talk 'A Tour of Scala 3'.
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...PROIDEA
Object-oriented programming languages have been here for decades, helping millions of developers to deliver (sort of) working software. Still, after many years, we still struggle with things like nulls and exceptions, which make our applications crash in most unexpected ways. So I have taken a challenge - can you use object-oriented language (C#) and write code in a way that those issues are almost gone? I will show how to leverage lessons learned from functional programming to make our applications more bulletproof - and fun to write as well!
This talk is a brief overview of how we deal with UI test architecture on our project. Complex backend, SPA as a frontend, 20+ different brands and 100+ features for each, more and more code.
We will discuss:
– fakes and test doubles, approaches how to build and maintain them;
– development patterns, which help you to make your architecture more simple, stable and readable;
– tips and tricks – how to make your life with UI tests easier.
Using feature teams to deliver high business valueThoughtworks
A view into how most IT organisations structure their teams to deal with business demands and possible inefficiencies that emerge as a result. An alternate to the traditional project team composition is a way to deliver end to end features to the business, using what is known as feature teams.
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
In the dynamic field of DevOps, the quest for efficiency and productivity is endless. This talk introduces a revolutionary toolkit: Large Language Models (LLMs), including ChatGPT, Gemini, and Claude, extending far beyond traditional coding assistance. We'll explore how LLMs can automate not just code generation, but also transform day-to-day operations such as crafting compelling cover letters for TPS reports, streamlining client communications, and architecting innovative DevOps solutions. Attendees will learn effective prompting strategies and examine real-life use cases, demonstrating LLMs' potential to redefine productivity in the DevOps landscape. Join us to discover how to harness the power of LLMs for a comprehensive productivity boost across your DevOps activities.
An architect’s job is to reduce complexity, not increase it. Yet the developer life is filled with jargon, acronyms, and seemingly infinite choices. So how do we know when complexity makes sense? We’ll learn when abstractions are justified and discuss how to structure applications so they’re maintainable, scalable, and testable.
We’ll make sure everyone is comfy with the core jargon like N-Teir, separation of concerns, and loose coupling. Then we’ll dive into various patterns for implementing the three common layers: data access, business logic, and presentation. You’ll learn when table module, active record, DDD, and ORMs make sense and walk away with the tools to better evaluate and justify complexity. We’ll focus on the value of keeping things simple whenever we can. Examples are presented in C# in Visual Studio but developers in Java, PHP, and other C-like languages should be able to follow right along.
Uladzimir Kalashnikau (EPAM Systems): Magento 2 Import/Export: Performance Challenges and Victories We Got at Open Source Ecommerce
Владимир Калашников (EPAM Systems): Импорт/экспорт для Magento 2: решение проблем производительности и наши успехи в open source e-commerce
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Maruthi Prithivirajan, Head of ASEAN & IN Solution Architecture, Neo4j
Get an inside look at the latest Neo4j innovations that enable relationship-driven intelligence at scale. Learn more about the newest cloud integrations and product enhancements that make Neo4j an essential choice for developers building apps with interconnected data and generative AI.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
3. No Functional Programming experience is
required
Experience in C# or other Object Oriented
languages helps
Basic understanding of Trains
Prerequisites
4. Set the scene
Working on a team at AGL
Discussions about code cleanliness comes up
regularly
Wanted to help out
This is the story
8. Sad Path
Increases the size of
the code
Makes it less
readable
Losing the domain of
the code
9. ModelView Controller
Model View Controller (MVC)
first used at Xerox in the 1970s
Popularised on the web thanks
to Ruby on Rails.
Fat Controller and Fat Model
problem
10. The Service Layer
Enterprise Application
Architectures by Martin
Fowlers
Manipulate the model
Can the controller show us
the flow
12. Goals
Happy Path code without sacrificing error
checking
Remove the God Object and compose smaller
functions
Make the controller show the data flow
Introduce some Functional Programming
concepts
Learn something new and have fun!
14. C# and Functional
Programming
Lambda expressions
LINQ
Better tuple support,
Pattern matching
Read only collections
Local functions
etc
15. Functional ApproachTo Error
Handling Scott Wlashin
https://fsharpforfunandprofit.com/rop
Marcus Denny from ALT.NET
Vladimir Khorikov – Microsoft MVP from
Washington DC
https://enterprisecraftsmanship.com
The railway is the analogy
Happy path programming
18. Result
Holds either success or
failure
Can hold errors on failure
Holds a value on success
Is immutable
Recreated on each call
Can transform the type
Success Failure
Input
19. F# Results
Native support F# 4.1 (early 2017)
https://docs.microsoft.com/en-
us/dotnet/fsharp/language-
reference/results
Has Error and Ok as keywords
Can we do this in C# ?
22. ErrorType
Store all the business
errors in an enumeration
Forces you to handle all
errors
Keeps all the errors
together
Could be a big ugly in
size
23. Exceptions
Exceptions are for
exceptional
circumstances
Don’t use for control
flow
Good use for I/O errors
50. Developer Feedback
Liked the reduced nesting
Was more readable
Service layer broken down into reusable parts
Is showing dataflow better
Bit of a learning curve
Bit difficult to debug
Preferred the OnSuccess/OnFailure over Map,
Bind
51. State machines
Validation
Business logic
Lambdas/ Azure Functions
Good Use Cases
52. Code shows the Happy Path without sacrificing
error checking
Compose smaller reusable functions
The controller shows the data flow
Learned some minor Functional Programming
concepts
And have fun!
Recap Goals
Take us back a year from now. We we're happy developers coding away.
However, as usual, we kept having difficulties deciding what we considered to be "clean" code.
Difference between code cleanliness and code quality
After many meetings, and broken design patterns we opted to give a functional approach a go.
Raise your hand if you’ve ever had any discussions about code cleanliness
This was originally proposed as a solution to some of the issues we had discussing code cleanliness
Let’s see how it works and how it worked out
3 Mins
We’re going to implement a simple API
You could image it being what’s behind this technology you may have used
We’re not going to show some real world code.
None of this code is legit code, or for that matter; is intended to make any sense
It’s purpose is to convey a problem and show the solution
It’s something we could all be somewhat familiar with
1. Validate request
2. Charge the credit card
3. Update balance
4 Return receipt
Looks pretty simple
So, this is generally how your code starts off
Explain code
In reality we have to deal with validation, logging, errors, exceptions etc
Throw some null checks in
Test return conditions
Add some Try catches
Lots of if statements for error handling
Plus some logging, if you’re lucky
Can turn 6 lines of code in 19
How many people have this problem?
How can we make the code more readable without sacrificing our standard checks?
We’ve also have another problem
Were does the business logic go?
In the MVC design pattern, the controller manipulates the model and the view generates the content based off the model.
Create reusable business logic
Who remembers the fat model / fat controller arguments?
Do we put it all in the controller or the model?
This is something I’ve seen in projects for years.
“Where does my business logic lie”
After following Martins Fowlers advice or reading Enterprise Application Architectures you’ll probably be in favour of the service layer
But we can keep coming back to the same issue of the God Object
We’ve had solutions in the past but it keeps reoccurring
It’s coined the God Object, where all the important code lies where it’s just more connected to everything than it should be
Other patterns like MVVM explicitly separate the business logic a bit better
CQS seems with frameworks like the mediator patterns gets you a bit out of this problem
But we have we solves the problem
We want:
No separation of concern
Ease of reusability
By making and composing smaller functions
7 mins
F# code is pretty neat
We've got lots of different styles to programming such as Object Oriented (C#, Java), Event driven, Procedural, declarative etc
Railway oriented programming is more of a design pattern than a rule to the above
Functional programming is another which is slowly entering the mainstream more each year
This has affected our programming in some ways
For example, C# 3 brought us lambda expressions, LINQ and now we have better tuple support, pattern matching, expression bodied members, read only collections, local functions
Other libraries bought us ReactiveX with rx.net, language-ext
So why can’t we have a functional approach to error handlng
Can we have a functional approach to error handling?
Will it help show us the flow of the code to neaten it up?
It was originally popularised by Scott Wlaschin in his talk at NDC Oslo which is entirely in F#
The name railway is there to help explain the concept as a metaphor for how the errors are handled
Scott Wlashin also has blogged about ROP which is one of his top hits which you can check out further if you're
Other developers have also attempted to convert this into c#
My main inspiration was Marcus Denny from alt.net!
Vladimir Khorikov MVP from Washinton DC
Functional programming in C# course on pluralsight
It’s rather simple but takes a little practice
We want to code for the happy path
As the input comes in here, it enters the function
Which returns whether the result of that function was a success or failure
The tracks are you input and output into your function
Use switches to join the tracks together
We can have many different types of tracks and switches which compose all of the functions together
On the success line we can carry different types to be the next input
10 Mins
This is easiest to start with in my opinion
Either monad is either right or left
Holds either success or failure
When successful holds the returned data
Can hold errors on failure
Chain these two tracks together
Native support in F# 4.1 (2017)
Thanks to discriminated unions!
Mentioned by Microsoft in their documentation
Wont be covering F# only in C#
Alternative - Can store Tsuccess Tfailure to return a data in the failed component
15 mins
This way you can process it with more information
Store all the different types of errors in an enumeration
Keeps all the errors together
Serves as documentation
Forces you to handle all errors
Type safety for testing
Could be a big ugly in size
Who would prefer to return false, raise your hand?
Exceptions follow like a GOTO statement – hard to read
Don’t use it for control flow
Can be slower – compilers generally don’t optimise for exceptions as control flow
Generally used for I/O problems
Global Exception handlers
17 Mins
The railway analogy
Can we get it really the same a F# -> no
Two track function is a function which returns a result type
Useful for most cases
Single track function is just a function which returns a value
The easiest one, but can be a bit tricky to join
No failure
You can lift these with the switches
Single track function is just a function which returns a value
The easiest one, but can be a bit tricky to join
No failure
You can lift these with the switches
20 Mins
We’re connecting them up through extension methods based off of the result type
There are a few different types of switches
Explain Extension methods,
Explain func
Combiners aren’t explained in the next slides but the idea is you can connect say a Map and a
It’s not too hard
Explain extension method
Explain Func
If just an if statement on a result type to execute another function
Notice: The func return type
Notice: The switchfunction doesn’t use result as it retuns a result
The switch function can return a result which switches the tracks
An adapter that takes a switch function and creates a new function that accepts two-track values as input.
Can still transform types!
An adapter that takes a normal one-track function and turns it into a two-track function.
Switches are these maps but can change the success or fail based on the return type
Map is good for getting functions that done return a Result object to continue to follow the same path
Remember: The highlighted part is what is represented in this code
Notice: they both create a new result type on each switch. They cannot change tracks.
An adapter that takes two one-track functions and turns them into a single two-track function.
Same as map but executes on both branches
An adapter that takes a dead-end function and turns it into a one-track function that can be used in a data flow.
A constructor that takes a one-track value and creates a two-track value on the success branch.
Less used
A constructor that takes a one-track value and creates a two-track value on the success branch.
Less used
Coming back to the exception handling
These are a bit more custom, shown for an example
Exceptions one isn’t the best example, can I say pokemon exception
We can switch the result type here to the error path based on if an exception was throw or not
It’s a single track function because it has no result return type
This switch returns a success or fail
On success only
Can change tracks based on the single track return type
No result return type
Finally, you’ll need a adapter block to transfer the two tracks into some output
Not the best of examples
Tdata from result type can then become the returned data
This has to be kind of short and sweet to get the point across, but it’s not entirety accurate.
You can see how we’re returning a response based off of whether or not this was successful or not
Brings this together for output,
Lots of options for this depending on your desired outcome or where you intend to use this handle
30 Mins
Apply it to our problem
Chain together the functions with switches
Which will decrease the amount of error handling code
Making our controllers look pretty and understandable
Service layer will have reusable code
Lets see if we can make it happen
Easiest one to grasp first
There’s a few different ways we can approach this
Lets start with a bind, the most common and easiest.
We’ll create a two-track function for each
Could use the bool lift function shown earlier
Notice even though we’re returning a Two-Track, we excuse using the result with the _ score lambda
That underscore actually represents the accountNumber as in the previous example
We transform the type in the result with each call
We still have access to the scope of whatever has been passed in the parameters
No result prior to the first validate account call
I hope this is making a bit more sense
Again this exception code isn’t how you would implement it
Here we’ve actually used an expression bodied member which says our whole method is an expression!
You’re better off moving it into another method and have a result type returned but for the sake of a call you couldn’t change
On a successful result, update the card
Success or fail
Executes on the success branch
Return the same result with a different type
Remember: difference between the Map and the DoubleMap is that the double map will execute on both tracks
I know what you’re all thinking, where’s the handle
Before we get to that and wrap it all up, we have a bonus!
C# has operator overloading! We can give two methods the same name
All you legitimately do is name the methods OnSuccess, OnFailure, OnBoth, FailWith
Reduce the functional programming knowledge
Make it easier for developers to just type OnSuccess and provide what they want, it will find the method for you!
Reduces the thought process with no extra effort or errors
The money shot
It’s all the same Bind Map etc underneath
Reusable on other similar Actions
I could make another action that does something similar and join compose them together differently
It doesn’t look as cool as F# though
35 Mins
Come back to our story
We revaluated our ROP trial on the AGL team
Feedback was mostly positive
Siva: Liked how we no longer needed if statements. May want to use it again. Found it a bit tricky at first but felt others could understand it easily. Noticed it did break down the services into reusable functions and the action was showing dataflow better.
Anup: Thought the code was much more readable. Did notice that it broke down the service layer. Thought it was understandable at first but as the extension methods grew found it hard to work with. Thinks he needs more time to learn it and show a better understanding
Sudheerah: Found it a bit difficult to debug. Overall did find it more expressive.
Dylan: Once the extension methods started building up, he found it difficult to know what to use. There was a bit of a learning curve at the beginning to understand the flow of data. Felt that the flow of data was easy to read after it had been written.
Varan: Found the map bind confusing. Wasn’t a big fan of the functional wording. Preferred onsuccess on failure etc. Did like using it over if statements to check if something was successful or not.
Raghav: Thought the code turned out rather readable. Wanted to polish it up a bit more for future use.
Does it fit everywhere?
Validation could include like some sort of file parsing
40 mins
So if you’re not a fan of MVC, maybe you just want routes and commands to be processed instead
Becoming a bit more of a popular pattern
Single file please
If you’re interested further, learn functional programming