Archive for February, 2010

I’m such a friggin idiot—Day of Mobile has that Jay Freeman!

I’m hosting a conference in Chicago called Day of Mobile. At the end of the day, we are having a big time keynote from Jay Freeman. These days, he’s a rock star in the iPhone universe. For some reason, and I’m a complete moron for not realizing this until a few minutes ago, he is the same guy who brought the .NET world this little tool: Anakrino. If you are scratching your head and wondering why that would impress me, it’s because I’m getting older and I’ve used every .NET tool in the world. Anakrino was a mainstay at Microsoft to decompile .NET assemblies to read in C# and VB.NET. It was easier to use than grabbing the source code.

So, in the last few minutes, I’ve gone from realizing that we had a really awesome iPhone ninja speaking at the conference to realizing that we had one of those legendary brainiac developers at the conference. And, while I didn’t want to pimp the conference to my usual .NET readers, I now feel I should because he’s such a part of all of our everyday lives as .NET developers. I mean, the guy who single handedly wrote Anakrino. Holy friggin’ crap!

Leave a comment

Article on JSON/XML Went up at InformIT.com

If you develop on ASP.NET MVC and have a need to return the ViewData as JSON and XML as well as HTML, take a look at the article I posted over at InformIT.com today (2/10/10): http://www.informit.com/articles/article.aspx?p=1554970. This is a shortcut to providing REST endpoints without doing a whole lot of extra work. This article doesn’t worry about versioning but does tackle the whole “how do I avoid screen scraping and extra coding” problem. Enjoy!

1 Comment

My first DimeCast is up!

Thanks to Derik Whittaker for bugging me to do one of these. It was fun. Go check it out. It’s a presentation on how to use the WebCam on Silverlight 4.

http://www.dimecasts.net/Casts/CastDetails/162

Leave a comment

Visual Studio 2010 Beta–>RC install and ASP.NET

I installed the VS 2010 RC last night, after uninstalling the VS 2010 Beta. If you see that ASP.NET isn’t coming up/working on your machine, you may need to remap the ASP.NET handlers into IIS. To do that, go to the Microsoft.NET 4.0 folder on your machine (typically C:WindowsMicrosoft.NETFramework64v4.0.30128 on a 64-bit Windows install, C:WindowsMicrosoft.NETFrameworkv4.0.30128 on a 32-bit install). Once in that folder, run the following:

aspnet_regiis.exe -i

After doing this, your ASP.NET applications should start running again. This is the same trick that worked on earlier versions of .NET, but it’s been a while since we had a .NET upgrade. I thought this might help out a few of you out there.

Leave a comment

DataContract, Partial Types and Generated Code

The other day, a friend had an issue with a DataContract. He had an Entity Model that used DataContract serialization. The code, stripped down to its essence, had something like this:

[DataContract]
public partial class SomeClass
{
    [DataMember]
    public int MyInt { get; set; }
}

 

And this was all well and good. When transmitting SomeClass over the wire, the fields on the entity model were transmitted. Now, my friend is really smart, and he knew that his version of serialization had implicit serialization. So, when adding new fields, he relied on implicit field serialization by augmenting SomeClass in a separate file as:

public partial class SomeClass
{
    public string MyString { get; set; }
}

 

Lo and behold, the field MyString didn’t appear on the wire. Why was this? This is because partial classes are a compiler trick that hides itself at the assembly level. The assembly indicated that SomeClass is a type that has the following C# implementation:

[DataContract]
public partial class SomeClass
{
    [DataMember]
    public int MyInt { get; set; }

    public string MyString { get; set; }
}
 

This shows that MyString is not part of the data contract, so the field doesn’t get serialized. At the assembly level, no one knows that you separated the implementation across two files.

So, next time you are wondering why part of your object isn’t being serialized, see if you made any declarations about serialization on the type. If you did, you have turned off the automatic “magic” parts of serialization. Sometimes, wizards will make those decisions for you. One way to recognize that the work was done for you: look to see if the generated type has [DataContract] on the partial class you are augmenting.

Leave a comment

Programmer Productivity

It’s been almost 4 years since I last programmed professionally with C++. C++ was my language of choice from 1994 through the end of 2000. It is a language that, once upon a time, I knew REALLY well. How well? I could read template errors and code the fix based on the build output-if you are a .NET developer, that’s kind of hard to do. Since then, I’ve done a lot of development with three languages: VB.NET, C#, and F#. Most recently, I was doing my hobbyist development in F#. I was impressed by the incremental boost in development productivity in F# over C#. The productivity boost at first was just noticeable and has recently become something where I can express F# algorithms in significantly less time that the C# equivalent.

Since mid November 2009, I started using C++ because a hobby project I wanted to work on required it. The project is a .NET profiler, and you can’t write a .NET profiler in .NET-you have to go to an unmanaged language. I noticed that I’m expressing C++ code at about the same rate as in F# and C#. At first, I was frustrated at the amount of functionality I could code in a few hours of C++ programming versus the same time slice in C#/F#. After talking to some friends, I was reminded that this is a thing that most people know but few people experience: each individual writes code at their own pace. Once they reach a level of expertise across 2 or more languages, they will write more functionality in the language that offers a higher level of abstraction. Unfortunately, not all languages can be used in all situations. The highest level of abstraction I can use for my profiler is C++.

If you do nothing else this year, learn a functional language to compliment the work you do in C#, VB.NET, Java, or C++. F#, Haskell, Clojure, Scala, and LISP all await to increase the amount of functionality you deliver every day. 

Leave a comment