万本电子书0元读

万本电子书0元读

顶部广告

Functional C#电子书

售       价:¥

31人正在读 | 0人评论 9.8

作       者:Wisnu Anggoro

出  版  社:Packt Publishing

出版时间:2016-12-01

字       数:247.3万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Uncover the secrets of functional programming using C# and change the way you approach your applications forever About This Book This book focuses on the functional paradigm of C#, which will give you a whole new angle on coding with C# It illustrates the advantages that functional programming brings to the table and the associated coding benefits This practical guide covers all the aspects of functional programming and provides solutions that can be applied in business scenarios Who This Book Is For This book is suitable for C# developers with basic prior knowledge of C# and with no functional programming experience at all. What You Will Learn Develop an application using the functional approach Implement unit testing to functionally program code Create efficient code using functional programming Work through a LINQ query so you can work with data Compose asynchronous programs to create a responsive application Use recursion in function programming in order to simplify code Optimize the program code using Laziness and Caching Techniques In Detail Functional programming makes your application faster, improves performance, and increases your productivity. C# code is written at a higher level of abstraction, so that code will be closer to business requirements, abstracting away many low-level implementation details. This book bridges the language gap for C# developers by showing you how to create and consume functional constructs in C#. We also bridge the domain gap by showing how functional constructs can be applied in business scenarios. We’ll take you through lambda expressions and extension methods, and help you develop a deep understanding of the concepts and practices of LINQ and recursion in C#. By the end of the book, you will be able to write code using the best approach and will be able to perform unit testing in functional programming, changing how you write your applications and revolutionizing your projects. Style and approach This book takes a pragmatic approach and shows you techniques to write better functional constructs in C#. We’ll also show you how these concepts can be applied in business scenarios.
目录展开

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

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部