You are previewing Functional Programming in C#: Classic Programming Techniques for Modern Projects.

Functional Programming in C#: Classic Programming Techniques for Modern Projects

  1. Cover
  2. Title
  3. Copyright
  4. About the Author
  5. Credits
  6. Contents
  7. Introduction
  8. Part I : Introduction to Functional Programming
    1. Chapter 1 : A Look at Functional Programming History
      1. What Is Functional Programming?
      2. Functional Languages
      3. The Relationship to Object Oriented Programming
      4. Summary
    2. Chapter 2 : Putting Functional Programming into a Modern Context
      1. Managing Side Effects
      2. Agile Programming Methodologies
      3. Declarative Programming
      4. Functional Programming Is a Mindset
      5. Is Functional Programming in C# a Good Idea?
      6. Summary
  9. Part II : C# Foundations of Functional Programming
    1. Chapter 3 : Functions, Delegates, and Lambda Expressions
      1. Functions and Methods
      2. Reusing Functions
      3. Anonymous Functions and Lambda Expressions
      4. Extension Methods
      5. Referential Transparency
      6. Summary
    2. Chapter 4 : Flexible Typing with Generics
      1. Generic Functions
      2. Generic Classes
      3. Constraining Types
      4. Other Generic Types
      5. Covariance and Contravariance
      6. Summary
    3. Chapter 5 : Lazy Listing with Iterators
      1. The Meaning of Laziness
      2. Enumerating Things with .NET
      3. Implementing Iterator Functions
      4. Chaining Iterators
      5. Summary
    4. Chapter 6 : Encapsulating Data in Closures
      1. Constructing Functions Dynamically
      2. The Problem with Scope
      3. How Closures Work
      4. Summary
    5. Chapter 7 : Code Is Data
      1. Expression Trees in .NET
      2. Analyzing Expressions
      3. Generating Expressions
      4. .NET 4.0 Specifics
      5. Summary
  10. Part III : Implementing Well-known Functional Techniques in C#
    1. Chapter 8 : Currying and Partial Application
      1. Decoupling Parameters
      2. Calling Parts of Functions
      3. Why Parameter Order Matters
      4. Summary
    2. Chapter 9 : Lazy Evaluation
      1. What’s Good about Being Lazy?
      2. Passing Functions
      3. Explicit Lazy Evaluation
      4. Comparing the Lazy Evaluation Techniques
      5. How Lazy Can You Be?
      6. Summary
    3. Chapter 10 : Caching Techniques
      1. The Need to Remember
      2. Precomputation
      3. Memoization
      4. Summary
    4. Chapter 11 : Calling Yourself
      1. Recursion in C#
      2. Tail Recursion
      3. Accumulator Passing Style
      4. Continuation Passing Style
      5. Indirect Recursion
      6. Summary
    5. Chapter 12 : Standard Higher Order Functions
      1. Applying Operations: Map
      2. Map, Filter, and Fold in LINQ
      3. Standard Higher Order Functions
      4. Summary
    6. Chapter 13 : Sequences
      1. Understanding List Comprehensions
      2. A Functional Approach to Iterators
      3. Ranges
      4. Restrictions
      5. Summary
    7. Chapter 14 : Constructing Functions from Functions
      1. Composing Functions
      2. Advanced Partial Application
      3. Combining Approaches
      4. Summary
    8. Chapter 15 : Optional Values
      1. The Meaning of Nothing
      2. Implementing Option(al) Values
      3. Summary
    9. Chapter 16 : Keeping Data from Changing
      1. Change Is Good — not!
      2. False Assumptions
      3. Implementing Immutable Container Data Structures
      4. Alternatives to Persistent Data Types
      5. Summary
    10. Chapter 17 : Monads
      1. What’s in a Typeclass?
      2. What’s in a Monad?
      3. Why Do a Whole Abstraction?
      4. A Second Monad: Logging
      5. Syntactic Sugar
      6. Binding with SelectMany?
      7. Summary
  11. Part IV : Putting Functional Programming into Action
    1. Chapter 18 : Integrating Functional Programming Approaches
      1. Refactoring
      2. Writing New Code
      3. Finding Likely Candidates for Functional Programming
      4. Summary
    2. Chapter 19 : The MapReduce Pattern
      1. Implementing MapReduce
      2. Abstracting the Problem
      3. Summary
    3. Chapter 20 : Applied Functional Modularization
      1. Executing SQL Code from an Application
      2. Rewriting the Function with Partial Application and Precomputation in Mind
      3. Summary
    4. Chapter 21 : Existing Projects Using Functional Techniques
      1. The .NET Framework
      2. LINQ
      3. Google MapReduce and Its Implementations
      4. NUnit
      5. Summary
  12. Index
O'Reilly logo

INTRODUCTION

FUNCTIONAL PROGRAMMING is an important paradigm of programming that looks back on a long history. The subject has always been very relevant to people who teach others how to program — the clean and logical concepts of functional programming lend themselves especially well to teaching. Certain industries that use computers and self-written programs heavily have also found functional programming to be the most productive approach for their purposes. However, for many of the “mainstream” software manufacturers, functional programming has long held an air of the academic and they widely chose to use approaches with an imperative heritage, like object orientation.

In recent years, more and more functional elements have been included in imperative languages on the .NET platform, and with Visual Studio 2010, F# has been included — the first hybrid functional language in the box with Microsoft’s mainstream development platform. Even more than the functional features that have been introduced to C# and VB.NET, this shows a commitment on Microsoft’s side.

WHO THIS BOOK IS FOR

The topic of functional programming in C# can be seen from two different angles. On the .NET platform there are many experienced developers and development teams, who have been using C# or VB.NET, or in some cases C++, to create software for the platform. If you have that sort of experience, there are lots of reasons you should be looking into functional programming: it’s a clean and easily maintainable ...

The best content for your career. Discover unlimited learning on demand for around $1/day.