Imposing Order on Chaos with Reactive Extensions
by Jon Stonecash
Thu, Apr 01, 2010
Room:
Time:
0:00
The world of computing is becoming more and more parallel. A lot of the computing technology that we use is an attempt to hide the chaos of mouse and keyboard events, messages, and other asynchronous events from our programs. The approaches used to date have limited succeeded in part by limiting what can be done with parallel processes. The Reactive Extensions in .NET allow the program logic to handle external events as first class citizens. Programs can manipulate events using LINQ expressions.
Take the example of example of handling a drag-and-drop operation from a source region of the screen to target region. Without the Reactive Extension logic, this might take dozens of lines of code to keep track of the state of operation and to invoke the drop logic at the right time. With Reactive Extensions, you could handle this in as little as one line of code.
The Reactive Extensions are more than a shorthand for multiple lines of code; they are a different mindset. They provide a way to "collect" events and route them to the appropriate logic in a very simple way. The final bonus is that the Reactive Extensions provide a way to de-couple the event source from the event consumer in such a way that unit testing event handling is very simple and understandable.
About the Author
Jon Stonecash is a senior consultant at Magenic, a Microsoft Gold Partner consulting company. Jon Stonecash has worked in software development for much longer than he would like to admit. In that time Jon has had the opportunity to make most of the serious software development mistakes at least once. He has programmed in over a dozen languages including several different assembly languages, Fortran, COBOL, SNOBOL, classic Visual Basic, VB.NET, and C#. He has survived the structured programming revolution and the object-oriented revolutions (having inexplicably missed out on the sexual revolution). Jon's software development activities have included the development of operating systems, scientific and engineering applications, and enterprise systems. He has worked in every phase of software development from the initial specification of requirements through to customer support. Along the way, he picked up a BS in Mathematics and an MBA. He still has hopes of finding something that he can be reasonably good at. His long term interests center about databases and the aspects of the application that handle data access and business logic. He is also interested in the tools and processes that assist the development process. Jon can be reached at jons@magenic.com. Jon also has an active blog on "Designing Out Loud in the .NET Space" at http://blog.magenic.com/blogs/jons/default.aspx.