How to use expressions for clear and simple code
Using short and clear code makes it easy to understand what it’s doing. It’s also easier for you and others to read later on. Using expressions in C# can help us do this. Let’s learn how to shape our code with expressions.
The power of expressions – improving readability and maintainability
Expressions support the idea of immutability, a cornerstone of functional programming. Since expressions evaluate to a value and don’t modify the state of our program, they allow us to write code that’s less prone to bugs, easier to reason about, and simple to test.
One day, Steve received a phone call from his old friend Irene, a renowned author of children’s books. She had begun to notice that books with longer titles seemed to be more popular. To test her theory, she gathered the titles of all the top-selling books and asked Steve to develop a program to calculate the average title length...