Posted on 5/31/2008 4:26:00 PM by Justin Etheredge
I have been a bit quiet for the past two months on my blog, since I was doing a presentation at the code camp at the end up April. Well, I am doing a presentation at the upcoming June 5th Richmond .Net users group. For some reason when I get into working on my presentations (probably because I haven't done too many of them) I somewhat obsess over them. I write code and rewrite code, and google...google...google. I start becoming obsessed with exploring every little nook of something I am doing, and then in the end I still feel like I know nothing about my topic!
Well, my presentation coming up is on the features of C# 3.0 that have been borrowed from functional programming. It isn't a presentation about functional programming in C#, since C# is not a functional language. If you want to write functional code, write it in F#, you'll bang your head against the wall a lot less! I am mainly going to be talking about delegates, lambdas, closures, and higher order functions.
I am aiming this presentation at a intermediate level presentation, that is going to try to get at some more beginner content at the start. I don't want people who are not familiar with delegates and closures to be left out in the cold! Although I will assume that people at least know what delegates are, but I won't expect them to know what anonymous methods are or the fact that they are closures. I really want this presentation to be accessible, and I am worried that it is not going to be.
Closures, for some people (including me), can be some mind bending stuff. One of the things that I am going to do with closures is show how to do memoization. I feel like it is a very useful process, that can be explained in a somewhat simple manner. I am worried though that some people just won't be able to wrap their mind around it. So, I sincerely hope that I will be able to break it down enough for people to grok it. If I don't, I have failed.
On that note, I dropped currying and partial function application from my presentation. I just felt like their implementation in C# is extremely ugly, it is extremely complicated, and quite frankly its usefulness in a non-functional language is limited. It wasn't an easy decision, because mind bending stuff like that is just so exciting for me. Who knows why, I just love to look at a piece of code and say, what the heck does that do? Check it out...
public static Func<TArg1, Func<TArg2, TResult>>
Curry<TArg1, TArg2, TResult>
(Func<TArg1, TArg2, TResult> func)
{
return argument1 => argument2 => func(argument1, argument2);
}
I mean, just look at that. The first time I saw code like that I knew that an adventure was ready to being. It was like a kid staring through the front window of a candy store. And granted, once you understand it, some of the magic goes away but the adventure never ends. I am going to leave my currying code in my presentation project, just in case by some miracle we have some time at the end I can go into it. I doubt that will be the case though.
So, I am hoping that once my obsessing ends I am going to get back to doing some more blogging. I have a few great ideas for blog posts that came out of the Meet and Code dinner that we did the other night. So I can't wait to get them written up. I also have a few other ideas that I need to find time to get to. So, anyways, I hope that you can hold out for a few more days, and if you live in Richmond come see me talk on June 5th!
Posted on 5/30/2008 12:28:11 AM by Justin Etheredge
The May Meet and Code dinner at SnagAJob.com was a great success! We had about a dozen people there, and the theme was debugging. We talked about using adplus and WinDbg to debug IIS crashes. We also looked at debugging visualizers, and how to make them. We looked at the expression tree visualizer that ships in the VS2008 samples. That led into a good talk about expression trees, which led to anonymous types, linq, etc... It was great! That is exactly what I was hoping to get out of meetings like this! I want people to come and talk about things and let the discussion lead us. If people want to talk about one thing, then we can talk about it.
Does anyone have any ideas for a topic for next month? I had thought that we could continue our discussion of expression trees and linq. Anyone have any other ideas? I hope that everyone enjoyed tonights meeting and I hope you all come again!
Posted on 5/18/2008 2:21:00 PM by Justin Etheredge
We have an account and meeting setup on Microsoft's click to attend site. So, if you would like to sign up, please do! Also, please tell *everyone* (who is a developer) that you know about this! We really want to make these meetings a success! This month we are going to be focusing on debugging, so if you have some tips and tricks to share, please come ready to share them! If you have any ideas on future focuses for the group, please send them to me!
Here is the link to sign up: Meet and Code Signup
Posted on 5/15/2008 11:02:33 PM by Justin Etheredge
We are going to hold our third "Meet and Code" dinner ("Geek Dinner" if you will) on Thursday May 29th. SnagAJob.com is generously providing us with a meeting space. They are located at 4880 Cox Road, Suite 200 Glen Allen, VA 23060, which is in Innsbrook on Cox road just after you cross over Nuckols road.
The "Meet and Code" dinners are an open forum for developers to come and discuss anything any everything they want. You can give a mini-presentation if you want, or you could bring a problem that you have from work for other developers to take a look at. There will also be some food provided, some come hungry!
We have applied for an account on Microsoft's Click To Attend site, so we will add a signup link soon!
Posted on 5/8/2008 8:17:34 PM by Justin Etheredge
List<T> has a method called ForEach that takes an Action<T> delegate, and I wanted one for IEnumerable. I also had someone ask about it in my previous post. It wasn't hard to write, but I figured I would throw it up here for future reference and also in case anyone needed help getting theirs working. If anyone notices anything I did that was dumb you can give me feedback as well. I believe I actually implemented something similar to this a while back, but anyways... without further ado...
public static void ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
{ if (enumerable == null)
throw new ArgumentNullException("enumerable");
if (action == null)
throw new ArgumentNullException("action");
foreach (T item in enumerable)
{ action(item);
}
}
Hope it helps.