Experimental Stuff (RSS)

Experimental Stuff

Object-Relational Mapping with ADO.NET vNext

Microsoft has just released the August 2006 CTP (Community Technology Preview) version of the next version of ADO.NET. The most important new feature of ADO.NET vNext is/will be an Entity Framework which supports Object-Relational Mapping straight from ADO.NET. Does this mean typed DataSets will be a thing of the past soon? It's too early to tell, but they are surely going to be used far less in the architectures of 2007 and later...

What's also cool about it is that this Entity Framework integrates with LINQ, so you can run LINQ queries on Entity collections etc. Whenever you make a modification to an Entity object, it is marked "dirty" so that when changes to lists, collections and graphs are saved, only the dirty ones are actually saved, and then their status is restored to "clean" again. It's great to have that as part of the Framework -- I've been doing stuff like this using ReSharper templates and Visual Studio 2005 snippets, and now it's becoming standard behavior without requiring any custom coding. You can even split Entity objects over multiple tables -- so that certain properties of your entity are saved in one table and other properties in another table. It's reminiscent of Commerce Server's data aggregator.

Get it while it's hot!

with 0 Comments

The Gates Code

1

In the middle of the night, master coder Rupert Longdon got a phone call at his hotel in Sunnyvale, California. Longdon, who was an expert with modern symbols mostly found on computer keyboards and was in town to convert the local Java gurus to another development environment from way up North, was confused.
     "Mr Longdon?"
     "Speaking."
     "Mr Longdon, this is the Sunnyvale Police. My name is Captain Faché."
     "Yes?"
     "
Have you talked to any Java people recently?"
     Strange. Maybe the Sunnyvale Police knows why nobody showed up at his presentation earlier?
     "Yes. But there was nobody there."
     "Mr Longdon, this is because tonight, under very strange circumstances, Java got killed. I'm sending a car over to pick you up. We need your help to solve this mystery."

2

Half an hour later, Rupert Longdon stood over the dead corpse of Java. It was surrounded by strange symbols carved in the floor, visible only to the trained eye. Who could have done this? Longdon wondered. As if he could read his guest's mind, Faché answered.
     "Java did this to itself."
     "Java committed suicide? Why?"  Longdon couldn't believe it.
     Faché pointed to the strange symbols surrounding Java's lifeless shell. Very bizarre indeed. On Java's left side were the following words and numbers:

8 5 0 13 3 1 2 1 21 ...
Bag, Sell It!
A Stud, Louis IV!

On Java's right side was simply written:

.NET

     "Does all of this mean anything to you?" Faché wondered.
     "Only that I've read about a similar case recently, during my vacation," Longdon responded. "But that is not relevant here."

3

Longdon studied the symbols carefully, made some calculations and was happy to give Captain Faché, who was getting anxious to crack the case quickly, an answer to the first riddle.
     "NET can be read backwards, saying 'TEN'. This probably means that Java was attacked by ten maniacs, backwards. This would also explain the dot at the beginning of .NET, which would signify the end, when read back to front."
     "Interesting hypothesis," Faché had to acknowledge. "What about the rest?"
     "The rest was written by someone who knows more about math than Dan Brown, the mystery author."
     "Oh? Why is that?" Faché wanted to know.
     "Because the number 0 is included. This, my dear Captain, is the beginning of the Fibonacci sequence, including the zero."
     "Mr Brown omitted the zero, is that what you're saying?"
     "Indeed," Longdon replied. "And he forgot to mention that the Fibonacci sequence is endless -- it doesn't end at 21."

Faché had to admit that his guest had a point. Which was unfortunate, because Faché had hoped to frame him for Java's demise. He decided to give it another try anyway.
     "What about the funny order of the numbers? Isn't the Fibonacci sequence in order?"
     "That is right. It goes 0, 1, 1, 2, 3, 5, etc. Maybe Java was dyslexic, that would explain what we're seeing here."
     "Mr Longdon," Faché replied calmly, "I can assure you that with assumptions like the ones you make, you're not going to make many friends in some communities that may read my report. What else can you tell me?"
The computer symbologist gave it some thought.
     "Maybe the other lines are in the wrong order, too. Maybe 'Bag, Sell It' has to be changed somehow, mingled, mixed, repositioned, to point to the Java killer."
He didn't realize at the time how right he was. "Ti Less Gab" was not the answer, but Longdon was close.

4

"I think we have to look for the solution somewhere else," offered Sophie VB, the just-arrived cryptologist who invented the late-bound variant-type variable. "I mean, let's look at the rivals of Java. Who would be happy with Java's demise?"
     Faché decided to have a go.
     "Starbucks?"
     "Close, but no cigar. Bag, Sell It is an anagram..."
     "Of Bill Gates!" Longdon exclaimed. And indeed it was.
     "Java points to Bill Gates as the reason it was dying?" Faché wondered. "It makes sense. What about the bottom line?"
     "The bottom line is that .NET, certainly the new version, is becoming the development environment of choice for many programmers who used to code in Java," Sophie replied.
     "No, I mean, the bottom line of the riddle?"
     "The reason Java was dying when it wrote down the mysterious symbols?"
     The three of them looked at the desperate cry for help that was carved in the floor next to Java's corpse.

A Stud, Louis IV!

What could it mean?

with 2 Comments

Fun with Interfaces, Part 2

Remember the post on Fun With Interfaces? Let's take this a step further...

The model from last time was the following:

 

ICouple inherits from IAlice and IBob; if you instantiate Carol, who implements IAlice and IBob, you can call the methods on both IAlice and IBob, but Carol does not automagically implement ICouple. However, if Carol was defined to implement ICouple, you could cast her to IAlice and to IBob and that would work:

ICouple carolOne = new Carol();
string
carolA = carolOne.AliceSays();
string carolB = carolOne.BobSays();

carolA = ((IAlice) carolOne).AliceSays();
carolB = ((IBob) carolOne).BobSays();

This works, but interestingly enough, at development time IntelliSense can't really figure it out -- it does display AliceSays() in the list of methods, but not BobSays(). But it does compile and run just fine.

Now, let's make the model a bit more complex:

We still have the same interfaces, but now we have a new type called OddCouple which implements both ICouple and IBob.

OddCouple can implement both these methods:

public virtual string AliceSays()
{
   
return
"Alice";
}

public virtual string BobSays()
{
   
return
"Bob";
}

Question 1: What will this do at compiletime, and at runtime?

The following code is expected to work, and in fact it does:

ICouple theTwo = new OddCouple();
string
whatBobSays = theTwo.BobSays();
string
whatAliceSays = theTwo.AliceSays();

The code in this example also works, as you'd expect:

IBob mrBob = new OddCouple();
whatBobSays = mrBob.BobSays();

After all, OddCouple implements IBob explicitly. Now, what happens when you try the following?

IAlice mrsAlice = new OddCouple();
whatAliceSays = mrsAlice.AliceSays();

Question 2: To make matters even more complicated, we have another type called OdderStill which inherits from OddCouple and explicitly declares that it implements IAlice. What will this do at compiletime, and at runtime?

Question 3: Do I have too much time on my hands?

 

with 2 Comments

Visual Studio 2005 Beta 2 probably to be released on March 31

I had hoped we'd see the bits of Visual Studio 2005 "Whidbey" by the January timeframe, nicely in time for the Developer & IT Pro Days in Belgium on 1 and 2 February, or the VSLive! conference in San Francisco. Unfortunately, it appears that Microsoft has its eyes on a March 31 release date for the new bits, which will be fully supported -- meaning software companies can release production software built with it and enjoy Redmond's support.

Beta 2 will have a slightly different API from Beta 1, ASP.NET will feature a different directory structure than Beta 1 and especially System.Xml will receive a major overhaul... So if you're developing with Beta 1 or the December CTP, keep in mind that after March 31 you'll need to make some changes to your code.

Currently, the development team is doing a security push on the Beta 2 bits, meaning that when the code is released, it will be considered secure... and probably the bug-freest development environment Microsoft has ever released. I wish it was already here!

with 2 Comments

MbUnitForms: A port of NUnitForms to use MbUnit instead

I have always considered one of the great advantages of NUnit the fact that it is supported by so many tools out in the field. This is something that, so far, MbUnit does not enjoy, even though it is a vastly superior tool.

So today I set out to try an experiment: to port an NUnit extension project, NUnitForms, to MbUnit to create MbUnitForms. And it was surprisingly easy to port the main part of the application.

NUnitForms is an open-source extension to NUnit to test WinForms applications. Unit-testing UIs is a major headache and this extension makes it possible. A typical NunitForms test contains tester controls for automatically filling in text boxes, "clicking" buttons, verifying content of text boxes and labels, etc. Very useful but so far only available for use with NUnit (for ASP.NET developers, there is a similar utility available called NUnitASP which should be just as easy to port as NUnitForms.)

The trick? Just "correct" the references (to the MbUnit.Core and MbUnit.Framework assemblies), do the same to the Using statements (to use MbUnit.Core.Framework, MbUnit.Framework, MbUnit.Core and/or MbUnit.Core.Exceptions as necessary), and recompile. There's nothing more to it!

Maybe I'll put the sources of the straight-port "MbUnitForms" up on SourceForge, if nobody objects. Either way, it's great to know that NUnit projects port so easily to MbUnit!

with 3 Comments

Removing index entries from Word documents

I know, this has absolutely nothing to do with Smart Development or even with .Net development... It's just that I needed to totally remove all index entries from a Word document today, and unfortunately this great Office tool doesn't include such a feature (or have I missed it?). Therefore, I quickly wrote a hack in VBA for Word, and thought I'd share it with you:

Sub StripIndexEntries()
    Dim c As Long
    Dim fieldCode As String
   
    c = 1
    While (c <= ActiveDocument.Fields.Count)
        fieldCode = ActiveDocument.Fields(c).code
       
        If InStr(fieldCode, "XE ") > 0 Then
            ActiveDocument.Fields(c).Delete
        Else
            c = c + 1
        End If
    Wend
End Sub

That's it. Happy un-indexing!

with 0 Comments

C-Omega, extensions to C#

Microsoft Research is publishing some white papers about C-Omega, a research programming language (actually an extension to C#). It contains a "control flow extension for asynchronous wide-area concurrency (formerly known as Polyphonic C#)" and "a data type extension for XML and table manipulation (formerly known as Xen and as X#)".

It looks intriguing. Especially if you remember that Whidbey's Generics also started out as a Microsoft Research extension to C#...

with 0 Comments