Book description
Real world examples and practical techniques for functional programming in C# without the jargon and theory.In Functional Programming in C#, Second Edition you will learn how to:
- Use higher-order functions to reduce duplication and do more with less code
- Use pure functions to write code that is easy to test and optimize
- Write pleasant APIs that accurately describe your program's behavior
- Use dedicated types to handle nullability, system errors, and validation rules predictably and elegantly
- Write composable code without the overhead of an IoC container
Functional Programming in C# has helped thousands of developers apply functional thinking to C# code. Its practical examples and spot-on treatment of FP concepts makes it the perfect guide for proficient C# programmers. This second edition is fully revised to cover new functional-inspired features in the most recent releases of C#, including tuples, async streams, pattern matching, and records. Each chapter is packed with awesome perspectives and epiphany moments on how functional programming can change the way you code.
About the Technology
Turbocharge your C# code. Good functional techniques will improve concurrency, state management, event handling, and maintainability of your software. This book gives you practical answers to why, how, and where to add functional programing into your C# coding practice.
About the Book
Functional Programming in C#, Second Edition teaches functional thinking for real-world problems. It reviews the C# language features that allow you to program functionally and through many practical examples shows the power of function composition, data-driven programming, and immutable data structures. All code examples work with .NET 6 and C# 10.
What's Inside
- Higher-order functions reduce duplication and do more with less code
- Code based on pure functions is easy to test and optimize
- Write pleasant APIs that accurately describe your program’s behavior
- Write a Web API in a functional style
- Monadic composition with LINQ
About the Reader
For intermediate C# programmers.
About the Author
Enrico Buonanno studied Computer Science at Columbia University and has over 15 years of experience as a developer, architect, and trainer.
Quotes
An excellent practical book for using functional programming concepts in your C# applications.
- Foster Haines, J2 Interactive
If this is your first venture into functional programming, then this is the book you want. A great mixture of the new with the familiar.
- Mark Elston, Advantest
A must-read for all .NET developers.
- Jedidja Bourgeois, Freshly Coded Software
An extremely good presentation of functional concepts for C# developers.
- David Paccoud, Bioclinica
Publisher resources
Table of contents
- inside front cover
- Praise for the first edition
- Functional Programming in C#
- Copyright
- contents
- front matter
- Part 1. Getting started
- 1 Introducing functional programming
- 2 Thinking in functions
- 3 Why function purity matters
- Part 2. Core techniques
- 4 Designing function signatures and types
- 5 Modeling the possible absence of data
- 6 Patterns in functional programming
- 7 Designing programs with function composition
- Part 3. Functional designs
- 8 Functional error handling
-
9 Structuring an application with functions
- 9.1 Partial application: Supplying arguments piecemeal
- 9.2 Overcoming the quirks of method resolution
- 9.3 Curried functions: Optimized for partial application
- 9.4 Creating a partial-application-friendly API
- 9.5 Modularizing and composing an application
- 9.6 Reducing a list to a single value
- Exercises
- Summary
- 10 Working effectively with multi-argument functions
- 11 Representing state and change
- 12 A short introduction to functional data structures
- 13 Event sourcing: A functional approach to persistence
- Part 4. Advanced techniques
-
14 Lazy computations, continuations, and the beauty of monadic composition
- 14.1 The virtue of laziness
- 14.2 Exception handling with Try
-
14.3 Creating a middleware pipeline for DB access
- 14.3.1 Composing functions that perform setup/teardown
- 14.3.2 A recipe against the pyramid of doom
- 14.3.3 Capturing the essence of a middleware function
- 14.3.4 Implementing the query pattern for middleware
- 14.3.5 Adding middleware that times the operation
- 14.3.6 Adding middleware that manages a DB transaction
- Summary
- 15 Stateful programs and stateful computations
- 16 Working with asynchronous computations
- 17 Traversable and stacked monads
- 18 Data streams and the Reactive Extensions
- 19 An introduction to message-passing concurrency
- Appendix A. Working with previous version of C#
- Epilogue. What next?
- index
Product information
- Title: Functional Programming in C#, Second Edition
- Author(s):
- Release date: January 2022
- Publisher(s): Manning Publications
- ISBN: 9781617299827
You might also like
book
Functional Programming in C#
Functional Programming in C# teaches you to apply functional thinking to real-world problems using the C# …
book
Functional Programming with C#
After decades of relative obscurity, functional programming is finally coming into its own. With concise, easy-to-read …
book
Mastering JavaScript Functional Programming - Second Edition
Explore the functional programming paradigm and the different techniques for developing better algorithms, writing more concise …
book
High-Performance Programming in C# and .NET
Enhance your applications' performance using best practices for benchmarking, application profiling, asynchronous programming, designing responsive UIs, …