Transforming Your C# Code to Functional Style
summary
Shows concrete refactorings from imperative loops and classes to concise functional patterns: replaces index loops with LINQ Where/Select/ForEach, turns strategy interfaces into Func<double,double> instead of classes, implements a reusable measure(Func<T>) stopwatch wrapper that returns elapsed time, and uses lazy evaluation and FirstOrDefault with predicate for first-available selection. Claims fewer lines, easier parallelization, far simpler tests (no heavy mocking), and practical examples like prime filtering and timing that prove the transformed code compiles and runs.
AI-written summary · about
chapters (22)
- 0:00Introduction and motivation
- 1:18Imperative vs functional style
- 4:52First example with loops
- 8:48Internal vs external iterators
- 11:15Filtering collections
- 15:18Declarative vs imperative code
- 18:48Statements vs expressions
- 23:32Finding prime numbers functionally
- 27:35Refactoring imperative prime check
- 32:02Audience reflection on coding styles
- 35:31Debugging in functional style
- 37:26Parallelizing functional code
- 37:47Tell vs ask principle
- 39:58Functional room booking example
- 43:12Strategy pattern with functions
- 45:29Eliminating interfaces with lambdas
- 48:44Timing code execution functionally
- 51:42Measuring function performance
- 52:48Replacing inheritance with functions
- 55:05Lightweight design benefits
- 56:34Refactoring and future possibilities
- 57:40Summary and closing
related talks
43mTransforming your C# code to Functional Style
01h 08mThinking Functionally with C#
01h 09mFunctional Programming with C#
58mFunctional Techniques for C#
58mFunctional Programming with C#
01h 00mC#'s Functional Journey
56mChange your habits: Modern techniques for modern C#
01h 03mFunctional Programming with C#
