Refactoring to functions
In this section, we’ll explore some aspects of refactoring related to functional programming. Functional programming is an approach to programming that focuses on functions and their interactions instead of purely on objects and classes.
Functional programming has become more popular over the last decade and that popularity has influenced the C# language with the addition of new forms of syntax.
We’ll explore a few of the syntactical improvements related to functional programming and see how they can help make concise and flexible programs. While this is not a book about functional programming, we’ll still find ourselves exploring a few of these concepts in this section and Chapter 10, Defensive Coding Techniques.
Using expression-bodied members
To start dipping our toes into the waters of the more functional syntax, let’s take a look at the FindFlightById
method in FlightTracker
:
private Flight? FindFlightById(string...