售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Functional C#
Functional C#
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Tasting Functional Style in C#
Introducing functional programming
Understanding definitions, scripts, and sessions
Using substitution and simplification to evaluate the expression
Understanding the functions used for functional programming
Forming the definition
Currying
Comparison between functional and imperative programming
Preparing the C# compiler
Concepts of functional programming
First-class and higher-order functions
Function types
Function values
Pure functions
Recursive functions
Feeling functional in C#
Using mathematical concept to understand functional approach
Applying tuple for functional C#
Currying in C#
Pipelining
Method chaining
Transforming imperative code to functional code
The imperative code approach
The functional code approach
The GenerateOrderedList() method
The Main() method
The advantages and disadvantages of functional programming
Summary
2. Walkthrough Delegates
Introducing delegates
Simple delegates
Multicast delegates
Using the Delegate.Combine() and Delegate.Remove() methods
Using += and -= operators
Built-in delegates
Generic delegates
The Action and Func delegates
Distinguishing variance in delegates
Covariance
Contravariance
Summary
3. Expressing Anonymous Methods with Lambda Expressions
Getting to know anonymous methods
Creating anonymous methods
Using an anonymous method as an argument
Writing anonymous methods - some guidelines
Advantages of the anonymous methods
Lambda expressions
Transforming an anonymous method to a lambda expression
Creating a delegate type using lambda expresions
Expression trees and lambda expressions
Subscribing for events using lambda expressions
Using the event keyword
Using EventHandler or EventHandler<T>
The advantages of using lambda expression in functional programming
First-class functions
Closure
Summary
4. Extending Object Functionality with Extension Methods
Getting closer to extension methods
Creating an extension method
Extension methods in the code IntelliSense
Calling extension methods in the other assemblies
Referencing a namespace
Piggybacking a namespace
Leveraging the interface, collection, and object
Extending the interface
Extending the collection
Extending an object
Advantages of using extension methods in functional programming
Limitations of the extension method
Extending a static class
Modifying the method implementation in the existing class or type
Summary
5. Querying Any Collection Easily with LINQ
Getting started with LINQ
Deferring LINQ execution
Choosing between fluent syntax and query expression syntax
Understanding the LINQ fluent syntax
Understanding the LINQ query expression syntax
Enumerating standard query operators
Filtering
Projection
Joining
Ordering
Grouping
The set operation
Conversion methods
Element operation
Summary
6. Enhancing the Responsiveness of the Functional Program with Asynchronous Programming
Building a responsive application
Running a program synchronously
Applying threads in the program
Creating threads using thread pool
The asynchronous programming model pattern
Using the synchronous Read() method
Using the BeginRead() and EndRead() methods
Adding LINQ to the BeginRead() method invocation
The task-based asynchronous pattern
Introducing the Task and Task<TResult> classes
Applying a simple TAP model
Using the WhenAll() extension method
Wrapping an APM into a TAP model
Asynchronous programming with the async and await keywords
Asynchronous functions in functional programming
Summary
7. Learning Recursion
Exploring recursion
Working of the recursive routine
Refactoring an iteration to the recursion
Using tail recursion
Accumulator-passing style
Continuation-passing style
Indirect recursion over direct recursion
Recursion in a functional approach using LINQ Aggregate
Delving into the Aggregate method
Summary
8. Optimizing the Code using Laziness and Caching Techniques
Introduction to laziness
Lazy enumeration
Lazy evaluation
Nonstrict evaluation
Lazy initialization
The advantages and disadvantages of being lazy
Caching expensive resources
Performing initial computation
Memoization
Summary
9. Working with Pattern
Dissecting pattern matching in functional programming
Transforming data using pattern matching
Switching for pattern matching
Simplifying pattern matching
Welcoming the coming of pattern matching feature in C# 7
Introducing Monad as a design pattern
Creating the Monadic M<T> type
Implementing the generic data type to Monad
Implementing Monad to Lazy<T> and Task<T>
Rules of the Monad pattern
Summary
10. Taking an Action in C# Functional Programming
Developing functional programming in Windows forms
Creating the code behind a form
Creating the engine code in an imperative approach
Preparing class properties
Constructing the constructor
Clearing the properties
Appending the number to the display box
Preparing the mathematical operation
Formatting the input
Solving the calculation
Calculating the additional operation
Creating the engine code in the functional approach
Adding several new properties
Simplifying the pattern matching
Assigning the properties
Constructing the class by clearing the properties
Appending the inputted number to the text box
Preparing the operation
Formatting the input
Solving the calculation
Calculating the additional operation
Summary
11. Coding Best Practice and Testing the Functional Code
Coding best practices in functional C#
Preventing dishonest signatures
Refactoring a mutable class into an immutable one
Avoiding mutability and temporal coupling
Dealing with the side-effects
Separating the code from domain logic and mutable shell
Examining the code containing side-effects
Refactoring the AddRecord() method
Refactoring the RemoveRecord() method
Running domain logic in unit testing
Testing the AddRecord() method
Testing the RemoveRecord() method
Executing the test
Adding the mutable shell into code
Summary
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜