没有合适的资源?快使用搜索试试~ 我知道了~
首页Programming Reactive Extensions and LINQ
Programming Reactive Extensions and LINQ
需积分: 10 11 下载量 166 浏览量
更新于2023-05-31
评论
收藏 6.21MB PDF 举报
Programming Reactive Extensions and LINQ
资源详情
资源评论
资源推荐
iv
Contents at a Glance
About the Authors ...................................................................................................... xi
About the Technical Reviewer .................................................................................. xii
Acknowledgments ................................................................................................... xiii
Foreword ................................................................................................................. xiv
Introduction ............................................................................................................. xvi
■Chapter 1: Introducing LINQ and Rx ........................................................................ 1
■Chapter 2: Core LINQ ............................................................................................. 19
■Chapter 3: Core Rx ................................................................................................. 41
■Chapter 4: Practical Rx .......................................................................................... 57
■Chapter 5: Inside Rx .............................................................................................. 77
■Chapter 6: LINQ to SQL ........................................................................................... 91
■Chapter 7: Reactive Extensions for JavaScript ................................................... 111
■Chapter 8: ReactiveUI .......................................................................................... 125
■Chapter 9: Testing With Rx .................................................................................. 145
Index ....................................................................................................................... 153
www.allitebooks.com
xvi
Introduction
Right now, we as programmers are at an impasse—a transition period between the well-understood
world of imperative programming, and a world that is increasingly at odds with this model. In the ’80s,
everything was simple: one machine, one thread, no network.
CPUs are now scaling horizontally, adding more and more cores, instead of scaling the CPU speeds.
Network and disk performance are now increasingly requiring asynchronous I/O in order to build high-
performance solutions.
Our tools to write asynchronous code, however, haven’t kept up with the rest of the world—threads,
locks, and events are the assembly language of asynchronous programming. They are straightforward to
understand, but as the complexity of the application becomes larger, it becomes extremely difficult to
determine if a given block of code will run correctly with respect to the rest of the application.
We need a way to retain the asynchronous nature of modern applications, while also retaining the
deterministic nature of traditional imperative programming.
A compelling solution to these problems is functional reactive programming. This term sounds
academic and overwhelming, however, if you’ve ever written a formula in Excel, good news—you’ve
already done functional reactive programming.
Let’s go through that title piece by piece, starting with the word “functional.” Many people have a
definition of functional programming, often from their college computer science course that covered
Scheme or Common Lisp, usually something along the lines of, “it means never using variables.”
Instead, think of FP as a mindset: “How is the output of my program related to my input, and how
can I describe that relation in code?” In this book, we’ll examine Language Integrated Queries (LINQ), a
powerful technology that allows us to describe a result list based on an input list and a set of
transformations on that input.
The disadvantage to LINQ is that this technology only works on lists, not data that is incoming or
changing. However, there is a type of list that is hiding in plain sight, only disguised—events. Consider
the KeyUp event: for every key that the user presses, an object representing the key will be generated—
“H”–“e”–“l”–“l”–“o”.
What if we thought of an event as a list? What if we could apply everything we know about lists to
events, like how to filter them or create new lists based on existing lists?
Reactive Extensions allow you to treat asynchronous sources of information, such as events, and
reason about them in the same way that you currently can reason about lists. This means, that once you
become proficient with using LINQ to write single-threaded programs, you can apply your knowledge
and write similar programs that are completely asynchronous.
A warning: this book is not easy to understand on first grasp. Rx will stretch your brain in ways it’s
not used to stretching, and you, like the authors, will almost certainly hit a learning curve.
The results, however, are most definitely worth it, as programs that would be incredibly difficult to write
correctly otherwise, are trivially easy to write and reason with Reactive Extensions.
www.allitebooks.com
C H A P T E R 1
1
Introducing LINQ and Rx
In a sentence, LINQ is a powerful way to interact with and extract data from collections, while Rx is an
extension of LINQ targeted at asynchronous collections; that is, collections that will be populated
asynchronously, typically from web services or elsewhere in the cloud.
LINQ was introduced to C# programmers with C# 3.0. On the other hand, Reactive Extensions (Rx)
is an emerging technology, born in Microsoft DevLabs and adopted as part of a standalone full product
from Microsoft in 2011.
We believe that the use of LINQ will expand greatly in the next few years, especially in conjunction
with Reactive Extensions. Rx extends many of the principles and features of LINQ to a wide set of
platforms (including JavaScript) and will be a vital part of Windows Phone programming, where
asynchronous events are the rule. As the data we deal with becomes more complex, LINQ will help bring
order and clarity to .NET programming. Similarly, as more and more data is retrieved asynchronously
from the cloud, and elsewhere, Rx will help you create simpler, cleaner, and more maintainable code.
In this chapter you will learn why LINQ and Rx are important and you’ll examine some of the
fundamental operators of both LINQ and Rx. This will provide a context for the coming chapters in
which we’ll dive deeper into both LINQ and Reactive Extensions.
■ Note Throughout this book we use Rx as shorthand for Reactive Extensions, just as we use LINQ for Language
Integrated Query.
What LINQ Is
LINQ (Language Integrated Query)—pronounced “link”—extends .NET to provide a way to query and
transform collections, relational data, and XML documents. It provides a SQL-like syntax within C# for
querying data, regardless of where that data originates.
LINQ also brings a much more declarative or functional approach to programming than previously
available in .NET.
www.allitebooks.com
剩余181页未读,继续阅读
picasson
- 粉丝: 2
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- zigbee-cluster-library-specification
- JSBSim Reference Manual
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0