Thursday, April 30

Standard deviation in Silverlight using LINQ

For a security feature in a Silverlight project I needed to compute the standard deviation of a series. Googling for it I quickly found a code sample, but it dates from the days before LINQ, which makes it 70 lines-long.

Thanks to LINQ, you can write a method that computes a standard deviation with only 3 lines. It works with Silverlight 2 (and 3) and with whatever .NET 3.5 application (WPF, ASP.NET, ...). Here’s my code:

using System;
using System.Data.Linq;

public static class SecurityMaths
{
    public static double StandardDeviation(this IEnumerable<double> data)
    {
        double average = data.Average();
        var individualDeviations = data.Select(num => Math.Pow(num - average, 2.0));
        return Math.Sqrt(individualDeviations.Average());
    }
}

Note that I defined my method as an extension method, so that it can be used just like the Average LINQ method. Which means you can use it that way:

double[] numbers = new double[] { 2,4,4,4,5,5,7,9 };
double average = numbers.Average();
double standardDev = numbers.StandardDeviation();

What a clean code: it’s almost as obvious as the mathematical definition of the standard deviation. Thanks a ton, LINQ!

Tuesday, February 24

MCPD Windows Developer 3.5

Here are another two in my passed certifications series: MCDP Windows Developer 3.5 and MCTS Windows Forms 3.5. My full list of certifications is there.

6 certifications .NET 3.5 passed in a year right from their first day out, so now I can show off my expertise.

MCTS4 MCPD2 MCT2

Thursday, January 29

MCPD ASP.NET 3.5

MCPD(rgb)I’m now a Microsoft Certified Professional Developer, ASP.NET 3.5 Applications. Together with my previous certifications, that makes it up to prove my proficiency in ASP.NET 3.5, AJAX, WPF, Silverlight 2, ADO.NET and Windows Forms.

What makes me especially proud is that I had to answer the questions for this certification in half the time allowed since I did it during TechEd Barcelona and had to go back and take my shift.

Want to see which certifications I have? It’s on my site – or just go and grab my Microsoft official transcript.

Monday, January 19

Framework 3.5 and .NET Configuration Tool

When you install Visual Studio 2008 on your machine, you don't get the .NET Framework Configuration tool. You can still use caspol.exe and other command-line configuration tools, but in order to visualize Code Access Security trees I believe a GUI tool is better...

Well,  it's easy to get it back: just install the Microsoft .NET Framework 2.0 SDK. Yep, 2.0. Want more info about that? It's here.

Sunday, January 18

Microsoft helps us break their own limitations

If you're evaluating Visual Studio 2010 as I am, you may have noticed that Visual Studio 2010 won't run beginning January 1st. That's a time limit built into the software.

Instead of providing us with a fixed VHD, Microsoft simply explains how we may go around the software's time limits - sort of like a neighbor teaching me how to break through his house.

In any case, even if those steps lengthen the already long VHD installation process, thanks to Microsoft for letting us have a look at this CTP so early in their development lifecycle.

Wednesday, November 26

TechEd sessions from Barcelona

I was at TechEd Europe developers edition, and I wrote down summaries of the sessions I went to. They're in French, but you can still have them automatically translated...

Note: those are my notes for what was said. They don't reflect my personal point of view about the technologies mentioned.

Charts using ASP.NET 3.5

One of the most interesting features of ASP.NET 4.0 (Visual Studio 2010) is the Chart control, enabling us to create useful and stunning... charts. What's more, Microsoft just released this control for ASP.NET 3.5. For free.

For a quickstart, Microsoft provides us with a sample Web site you just have to open and run using Visual Studio 2008, exactly like you would with the Ajax Control Toolkit.

More information about this on Scott Guthrie's post.