Lambda expressions in C# – How useful are they really?

I’m currently working on a project where we are using a technology called DDS (Data Distribution Service). DDS is a Publish/Subscribe technology for Inter-Process Communication. It is fast, and very flexible in terms of the Quality-of-Service that you want. Now, I have developed a framework around it so that various parts of our application need only interact with a state class, and in fact they can register to be notified of changes to properties on these state classes. These state classes effectively register an interest in a particular Topic (the fundamental unit of data within DDS, a collection of repeated fields, a single occurrence of which is called a Sample). Now, when a class uses my framework to register an interest in a particular topic, it supplies an Action<T> which is used to process Samples of the Topic in question. In some cases I have passed a C# Lambda Expression in as the Action, but I find a key problem with these lambdas is that they are very hard to test (I’m pretty much doing TDD, not quite, but pretty much). I’m leaning towards the idea that if you can’t test it easily, it isn’t all that useful as language element. I’m interested to see what people think.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s