By John Sonmez June 18, 2010

The Power of Func<>

I remember why I love C#.

After spending the last two years or so writing mainly Java code, getting back into Visual Studio felt a little awkward and painful.

Where did all my keyboard shortcuts go?  Why can’t I navigate to members in a class?  Oh, yes Resharper… ah that’s better.

But then it happened.

I was minding my own business writing some code… la la la

Oh my, repeated code!  What ever shall I do?

Hmm… It varies by property names only.

Surely I can refactor out the override loading code.  Can’t put it in the constructor, because the goal is to lazy load the overrides from the database.

Func<> to the rescue!

This is the power of Func.  Of delegates really.  You can’t do this in Java folks… Hold on to your chair.  Here we go…. Whee…..

Good has won…

Evil has been defeated…

Code has been deleted

Thank you Func<>

Don’t forget the Super Combo!

Also, check out the new page I created, a compilation of useful posts I have written about building software in an Agile way.

About the author

John Sonmez

John Sonmez is the founder of Simple Programmer and a life coach for software developers. He is the best selling author of the book "Soft Skills: The Software Developer's Life Manual."